xmt_froala 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (203) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +28 -0
  4. data/Rakefile +2 -0
  5. data/app/assets/javascripts/xmt_froala.js +31 -0
  6. data/app/assets/stylesheets/xmt_froala.css +17 -0
  7. data/app/controllers/xmt_froala/application_controller.rb +5 -0
  8. data/app/controllers/xmt_froala/assets_controller.rb +94 -0
  9. data/app/models/xmt_froala/asset_uploader.rb +107 -0
  10. data/app/models/xmt_froala/file_uploader.rb +10 -0
  11. data/app/models/xmt_froala/flash_uploader.rb +10 -0
  12. data/app/models/xmt_froala/image_uploader.rb +10 -0
  13. data/app/models/xmt_froala/media_uploader.rb +10 -0
  14. data/config/routes.rb +6 -0
  15. data/lib/generators/xmt_froala/install/USAGE +10 -0
  16. data/lib/generators/xmt_froala/install/install_generator.rb +23 -0
  17. data/lib/generators/xmt_froala/install/templates/application.js +17 -0
  18. data/lib/generators/xmt_froala/install/templates/xmt_froala.rb +29 -0
  19. data/lib/generators/xmt_froala/migration/USAGE +14 -0
  20. data/lib/generators/xmt_froala/migration/migration_generator.rb +36 -0
  21. data/lib/generators/xmt_froala/migration/templates/migration/migration.rb +18 -0
  22. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/asset.rb +14 -0
  23. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/file.rb +3 -0
  24. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/flash.rb +3 -0
  25. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/image.rb +3 -0
  26. data/lib/generators/xmt_froala/migration/templates/models/active_record/xmt_froala/media.rb +3 -0
  27. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/asset.rb +27 -0
  28. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/file.rb +3 -0
  29. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/flash.rb +3 -0
  30. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/image.rb +3 -0
  31. data/lib/generators/xmt_froala/migration/templates/models/mongoid/xmt_froala/media.rb +3 -0
  32. data/lib/tasks/xmt_froala_tasks.rake +9 -0
  33. data/lib/xmt_froala.rb +65 -0
  34. data/lib/xmt_froala/active_record.rb +14 -0
  35. data/lib/xmt_froala/engine.rb +32 -0
  36. data/lib/xmt_froala/formtastic.rb +12 -0
  37. data/lib/xmt_froala/helper.rb +105 -0
  38. data/lib/xmt_froala/simple_form.rb +11 -0
  39. data/lib/xmt_froala/version.rb +3 -0
  40. data/vendor/assets/javascripts/xmt_froala/froala_editor.js +0 -0
  41. data/vendor/assets/javascripts/xmt_froala/languages/ar.js +318 -0
  42. data/vendor/assets/javascripts/xmt_froala/languages/bs.js +318 -0
  43. data/vendor/assets/javascripts/xmt_froala/languages/cs.js +318 -0
  44. data/vendor/assets/javascripts/xmt_froala/languages/da.js +318 -0
  45. data/vendor/assets/javascripts/xmt_froala/languages/de.js +318 -0
  46. data/vendor/assets/javascripts/xmt_froala/languages/en_ca.js +262 -0
  47. data/vendor/assets/javascripts/xmt_froala/languages/en_gb.js +262 -0
  48. data/vendor/assets/javascripts/xmt_froala/languages/es.js +318 -0
  49. data/vendor/assets/javascripts/xmt_froala/languages/et.js +318 -0
  50. data/vendor/assets/javascripts/xmt_froala/languages/fa.js +318 -0
  51. data/vendor/assets/javascripts/xmt_froala/languages/fi.js +318 -0
  52. data/vendor/assets/javascripts/xmt_froala/languages/fr.js +318 -0
  53. data/vendor/assets/javascripts/xmt_froala/languages/he.js +318 -0
  54. data/vendor/assets/javascripts/xmt_froala/languages/hr.js +318 -0
  55. data/vendor/assets/javascripts/xmt_froala/languages/hu.js +318 -0
  56. data/vendor/assets/javascripts/xmt_froala/languages/id.js +319 -0
  57. data/vendor/assets/javascripts/xmt_froala/languages/it.js +318 -0
  58. data/vendor/assets/javascripts/xmt_froala/languages/ja.js +318 -0
  59. data/vendor/assets/javascripts/xmt_froala/languages/ko.js +318 -0
  60. data/vendor/assets/javascripts/xmt_froala/languages/me.js +318 -0
  61. data/vendor/assets/javascripts/xmt_froala/languages/nb.js +318 -0
  62. data/vendor/assets/javascripts/xmt_froala/languages/nl.js +318 -0
  63. data/vendor/assets/javascripts/xmt_froala/languages/pl.js +318 -0
  64. data/vendor/assets/javascripts/xmt_froala/languages/pt_br.js +318 -0
  65. data/vendor/assets/javascripts/xmt_froala/languages/pt_pt.js +318 -0
  66. data/vendor/assets/javascripts/xmt_froala/languages/ro.js +319 -0
  67. data/vendor/assets/javascripts/xmt_froala/languages/ru.js +318 -0
  68. data/vendor/assets/javascripts/xmt_froala/languages/sk.js +318 -0
  69. data/vendor/assets/javascripts/xmt_froala/languages/sr.js +318 -0
  70. data/vendor/assets/javascripts/xmt_froala/languages/sv.js +318 -0
  71. data/vendor/assets/javascripts/xmt_froala/languages/th.js +318 -0
  72. data/vendor/assets/javascripts/xmt_froala/languages/tr.js +318 -0
  73. data/vendor/assets/javascripts/xmt_froala/languages/uk.js +318 -0
  74. data/vendor/assets/javascripts/xmt_froala/languages/vi.js +258 -0
  75. data/vendor/assets/javascripts/xmt_froala/languages/zh_cn.js +320 -0
  76. data/vendor/assets/javascripts/xmt_froala/languages/zh_tw.js +318 -0
  77. data/vendor/assets/javascripts/xmt_froala/plugins/align.js +139 -0
  78. data/vendor/assets/javascripts/xmt_froala/plugins/align.min.js +7 -0
  79. data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.js +154 -0
  80. data/vendor/assets/javascripts/xmt_froala/plugins/char_counter.min.js +7 -0
  81. data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.js +3270 -0
  82. data/vendor/assets/javascripts/xmt_froala/plugins/code_beautifier.min.js +7 -0
  83. data/vendor/assets/javascripts/xmt_froala/plugins/code_view.js +393 -0
  84. data/vendor/assets/javascripts/xmt_froala/plugins/code_view.min.js +7 -0
  85. data/vendor/assets/javascripts/xmt_froala/plugins/colors.js +492 -0
  86. data/vendor/assets/javascripts/xmt_froala/plugins/colors.min.js +7 -0
  87. data/vendor/assets/javascripts/xmt_froala/plugins/draggable.js +459 -0
  88. data/vendor/assets/javascripts/xmt_froala/plugins/draggable.min.js +7 -0
  89. data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.js +509 -0
  90. data/vendor/assets/javascripts/xmt_froala/plugins/emoticons.min.js +7 -0
  91. data/vendor/assets/javascripts/xmt_froala/plugins/entities.js +121 -0
  92. data/vendor/assets/javascripts/xmt_froala/plugins/entities.min.js +7 -0
  93. data/vendor/assets/javascripts/xmt_froala/plugins/file.js +736 -0
  94. data/vendor/assets/javascripts/xmt_froala/plugins/file.min.js +239 -0
  95. data/vendor/assets/javascripts/xmt_froala/plugins/font_family.js +182 -0
  96. data/vendor/assets/javascripts/xmt_froala/plugins/font_family.min.js +7 -0
  97. data/vendor/assets/javascripts/xmt_froala/plugins/font_size.js +118 -0
  98. data/vendor/assets/javascripts/xmt_froala/plugins/font_size.min.js +7 -0
  99. data/vendor/assets/javascripts/xmt_froala/plugins/forms.js +430 -0
  100. data/vendor/assets/javascripts/xmt_froala/plugins/forms.min.js +7 -0
  101. data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.js +274 -0
  102. data/vendor/assets/javascripts/xmt_froala/plugins/fullscreen.min.js +7 -0
  103. data/vendor/assets/javascripts/xmt_froala/plugins/help.js +216 -0
  104. data/vendor/assets/javascripts/xmt_froala/plugins/help.min.js +7 -0
  105. data/vendor/assets/javascripts/xmt_froala/plugins/image.js +3323 -0
  106. data/vendor/assets/javascripts/xmt_froala/plugins/image.min.js +7 -0
  107. data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.js +1056 -0
  108. data/vendor/assets/javascripts/xmt_froala/plugins/image_manager.min.js +7 -0
  109. data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.js +94 -0
  110. data/vendor/assets/javascripts/xmt_froala/plugins/inline_style.min.js +7 -0
  111. data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.js +537 -0
  112. data/vendor/assets/javascripts/xmt_froala/plugins/line_breaker.min.js +7 -0
  113. data/vendor/assets/javascripts/xmt_froala/plugins/link.js +1157 -0
  114. data/vendor/assets/javascripts/xmt_froala/plugins/link.min.js +7 -0
  115. data/vendor/assets/javascripts/xmt_froala/plugins/lists.js +462 -0
  116. data/vendor/assets/javascripts/xmt_froala/plugins/lists.min.js +7 -0
  117. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.js +290 -0
  118. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_format.min.js +7 -0
  119. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.js +144 -0
  120. data/vendor/assets/javascripts/xmt_froala/plugins/paragraph_style.min.js +7 -0
  121. data/vendor/assets/javascripts/xmt_froala/plugins/plain_paste.js +96 -0
  122. data/vendor/assets/javascripts/xmt_froala/plugins/print.js +137 -0
  123. data/vendor/assets/javascripts/xmt_froala/plugins/print.min.js +7 -0
  124. data/vendor/assets/javascripts/xmt_froala/plugins/quick_format.js +89 -0
  125. data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.js +478 -0
  126. data/vendor/assets/javascripts/xmt_froala/plugins/quick_insert.min.js +7 -0
  127. data/vendor/assets/javascripts/xmt_froala/plugins/quote.js +141 -0
  128. data/vendor/assets/javascripts/xmt_froala/plugins/quote.min.js +7 -0
  129. data/vendor/assets/javascripts/xmt_froala/plugins/save.js +189 -0
  130. data/vendor/assets/javascripts/xmt_froala/plugins/save.min.js +7 -0
  131. data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.js +781 -0
  132. data/vendor/assets/javascripts/xmt_froala/plugins/special_characters.min.js +7 -0
  133. data/vendor/assets/javascripts/xmt_froala/plugins/table.js +4194 -0
  134. data/vendor/assets/javascripts/xmt_froala/plugins/table.min.js +7 -0
  135. data/vendor/assets/javascripts/xmt_froala/plugins/url.js +194 -0
  136. data/vendor/assets/javascripts/xmt_froala/plugins/url.min.js +7 -0
  137. data/vendor/assets/javascripts/xmt_froala/plugins/video.js +2342 -0
  138. data/vendor/assets/javascripts/xmt_froala/plugins/video.min.js +7 -0
  139. data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.js +1403 -0
  140. data/vendor/assets/javascripts/xmt_froala/plugins/word_paste.min.js +7 -0
  141. data/vendor/assets/javascripts/xmt_froala/third_party/embedly.js +543 -0
  142. data/vendor/assets/javascripts/xmt_froala/third_party/embedly.min.js +7 -0
  143. data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.js +163 -0
  144. data/vendor/assets/javascripts/xmt_froala/third_party/image_aviary.min.js +7 -0
  145. data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.js +222 -0
  146. data/vendor/assets/javascripts/xmt_froala/third_party/spell_checker.min.js +7 -0
  147. data/vendor/assets/javascripts/xmt_froala/xmt_froala.js +15172 -0
  148. data/vendor/assets/stylesheets/xmt_froala/css/font-awesome.css +2546 -0
  149. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.min.css +7 -0
  150. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.css +2902 -0
  151. data/vendor/assets/stylesheets/xmt_froala/css/froala_editor.pkgd.min.css +7 -0
  152. data/vendor/assets/stylesheets/xmt_froala/css/froala_style.css +413 -0
  153. data/vendor/assets/stylesheets/xmt_froala/css/froala_style.min.css +7 -0
  154. data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.css +57 -0
  155. data/vendor/assets/stylesheets/xmt_froala/css/plugins/char_counter.min.css +7 -0
  156. data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.css +112 -0
  157. data/vendor/assets/stylesheets/xmt_froala/css/plugins/code_view.min.css +7 -0
  158. data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.css +155 -0
  159. data/vendor/assets/stylesheets/xmt_froala/css/plugins/colors.min.css +7 -0
  160. data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.css +43 -0
  161. data/vendor/assets/stylesheets/xmt_froala/css/plugins/draggable.min.css +7 -0
  162. data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.css +42 -0
  163. data/vendor/assets/stylesheets/xmt_froala/css/plugins/emoticons.min.css +7 -0
  164. data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.css +146 -0
  165. data/vendor/assets/stylesheets/xmt_froala/css/plugins/file.min.css +7 -0
  166. data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.css +28 -0
  167. data/vendor/assets/stylesheets/xmt_froala/css/plugins/fullscreen.min.css +7 -0
  168. data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.css +52 -0
  169. data/vendor/assets/stylesheets/xmt_froala/css/plugins/help.min.css +7 -0
  170. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.css +244 -0
  171. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image.min.css +7 -0
  172. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.css +266 -0
  173. data/vendor/assets/stylesheets/xmt_froala/css/plugins/image_manager.min.css +7 -0
  174. data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.css +37 -0
  175. data/vendor/assets/stylesheets/xmt_froala/css/plugins/line_breaker.min.css +7 -0
  176. data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.css +70 -0
  177. data/vendor/assets/stylesheets/xmt_froala/css/plugins/quick_insert.min.css +7 -0
  178. data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.css +51 -0
  179. data/vendor/assets/stylesheets/xmt_froala/css/plugins/special_characters.min.css +7 -0
  180. data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.css +181 -0
  181. data/vendor/assets/stylesheets/xmt_froala/css/plugins/table.min.css +7 -0
  182. data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.css +231 -0
  183. data/vendor/assets/stylesheets/xmt_froala/css/plugins/video.min.css +7 -0
  184. data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.css +1281 -0
  185. data/vendor/assets/stylesheets/xmt_froala/css/themes/dark.min.css +7 -0
  186. data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.css +1281 -0
  187. data/vendor/assets/stylesheets/xmt_froala/css/themes/gray.min.css +7 -0
  188. data/vendor/assets/stylesheets/xmt_froala/css/themes/red.css +1281 -0
  189. data/vendor/assets/stylesheets/xmt_froala/css/themes/red.min.css +7 -0
  190. data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.css +1281 -0
  191. data/vendor/assets/stylesheets/xmt_froala/css/themes/royal.min.css +7 -0
  192. data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.css +64 -0
  193. data/vendor/assets/stylesheets/xmt_froala/css/third_party/embedly.min.css +7 -0
  194. data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.css +72 -0
  195. data/vendor/assets/stylesheets/xmt_froala/css/third_party/spell_checker.min.css +7 -0
  196. data/vendor/assets/stylesheets/xmt_froala/css/xmt_froala.css +1423 -0
  197. data/vendor/assets/stylesheets/xmt_froala/fonts/FontAwesome.otf +0 -0
  198. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.eot +0 -0
  199. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.svg +2671 -0
  200. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.ttf +0 -0
  201. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff +0 -0
  202. data/vendor/assets/stylesheets/xmt_froala/fonts/fontawesome-webfont.woff2 +0 -0
  203. metadata +273 -0
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ !function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=function(e,a){return a===undefined&&(a="undefined"!=typeof window?require("jquery"):require("jquery")(e)),t(a)}:t(window.jQuery)}(function(O){if(O.extend(O.FE.DEFAULTS,{imageManagerLoadURL:"https://i.froala.com/load-files",imageManagerLoadMethod:"get",imageManagerLoadParams:{},imageManagerPreloader:null,imageManagerDeleteURL:"",imageManagerDeleteMethod:"post",imageManagerDeleteParams:{},imageManagerPageSize:12,imageManagerScrollOffset:20,imageManagerToggleTags:!0}),O.FE.PLUGINS.imageManager=function(o){var g,l,r,i,n,d,s,f,m,u,c,h="image_manager",e=10,p=11,v=12,M=13,w=14,b=15,C=21,L=22,t={};function y(){var e=O(window).outerWidth();return e<768?2:e<1200?3:4}function D(){n.empty();for(var e=0;e<c;e++)n.append('<div class="fr-list-column"></div>')}function I(){if(m<s.length&&(n.outerHeight()<=r.outerHeight()+o.opts.imageManagerScrollOffset||r.scrollTop()+o.opts.imageManagerScrollOffset>n.outerHeight()-r.outerHeight())){f++;for(var e=o.opts.imageManagerPageSize*(f-1);e<Math.min(s.length,o.opts.imageManagerPageSize*f);e++)a(s[e])}}function a(i){var n=new Image,s=O('<div class="fr-image-container fr-empty fr-image-'+u+++'" data-loading="'+o.language.translate("Loading")+'.." data-deleting="'+o.language.translate("Deleting")+'..">');T(!1),n.onload=function(){s.height(Math.floor(s.width()/n.width*n.height));var t=O("<img/>");if(i.thumb)t.attr("src",i.thumb);else{if(U(w,i),!i.url)return U(b,i),!1;t.attr("src",i.url)}if(i.url&&t.attr("data-url",i.url),i.tag)if(l.find(".fr-modal-more.fr-not-available").removeClass("fr-not-available"),l.find(".fr-modal-tags").show(),0<=i.tag.indexOf(",")){for(var e=i.tag.split(","),a=0;a<e.length;a++)e[a]=e[a].trim(),0===d.find('a[title="'+e[a]+'"]').length&&d.append('<a role="button" title="'+e[a]+'">'+e[a]+"</a>");t.attr("data-tag",e.join())}else 0===d.find('a[title="'+i.tag.trim()+'"]').length&&d.append('<a role="button" title="'+i.tag.trim()+'">'+i.tag.trim()+"</a>"),t.attr("data-tag",i.tag.trim());for(var r in i.name&&t.attr("alt",i.name),i)i.hasOwnProperty(r)&&"thumb"!=r&&"url"!=r&&"tag"!=r&&t.attr("data-"+r,i[r]);s.append(t).append(O(o.icon.create("imageManagerDelete")).addClass("fr-delete-img").attr("title",o.language.translate("Delete"))).append(O(o.icon.create("imageManagerInsert")).addClass("fr-insert-img").attr("title",o.language.translate("Insert"))),d.find(".fr-selected-tag").each(function(e,a){k(t,a.text)||s.hide()}),t.on("load",function(){s.removeClass("fr-empty"),s.height("auto"),m++,E(x(parseInt(t.parent().attr("class").match(/fr-image-(\d+)/)[1],10)+1)),T(!1),m%o.opts.imageManagerPageSize==0&&I()}),o.events.trigger("imageManager.imageLoaded",[t])},n.onerror=function(){m++,s.remove(),E(x(parseInt(s.attr("class").match(/fr-image-(\d+)/)[1],10)+1)),U(e,i),m%o.opts.imageManagerPageSize==0&&I()},n.src=i.thumb||i.url,P().append(s)}function P(){var r,i;return n.find(".fr-list-column").each(function(e,a){var t=O(a);0===e?(i=t.outerHeight(),r=t):t.outerHeight()<i&&(i=t.outerHeight(),r=t)}),r}function x(e){e===undefined&&(e=0);for(var a=[],t=u-1;e<=t;t--){var r=n.find(".fr-image-"+t);r.length&&(a.push(r),O('<div id="fr-image-hidden-container">').append(r),n.find(".fr-image-"+t).remove())}return a}function E(e){for(var a=e.length-1;0<=a;a--)P().append(e[a])}function T(e){if(e===undefined&&(e=!0),!g.is(":visible"))return!0;var a=y();if(a!=c){c=a;var t=x();D(),E(t)}o.modals.resize(h),e&&I()}function q(e){var a={},t=e.data();for(var r in t)t.hasOwnProperty(r)&&"url"!=r&&"tag"!=r&&(a[r]=t[r]);return a}function S(e){var a=O(e.currentTarget).siblings("img"),t=g.data("instance")||o,r=g.data("current-image");if(o.modals.hide(h),t.image.showProgressBar(),r)r.data("fr-old-src",r.attr("src")),r.trigger("click");else{t.events.focus(!0),t.selection.restore();var i=t.position.getBoundingRect(),n=i.left+i.width/2+O(o.doc).scrollLeft(),s=i.top+i.height+O(o.doc).scrollTop();t.popups.setContainer("image.insert",o.$sc),t.popups.show("image.insert",n,s)}t.image.insert(a.data("url"),!1,q(a),r)}function R(e){var t=O(e.currentTarget).siblings("img"),a=o.language.translate("Are you sure? Image will be deleted.");confirm(a)&&(o.opts.imageManagerDeleteURL?!1!==o.events.trigger("imageManager.beforeDeleteImage",[t])&&(t.parent().addClass("fr-image-deleting"),O.ajax({method:o.opts.imageManagerDeleteMethod,url:o.opts.imageManagerDeleteURL,data:O.extend(O.extend({src:t.attr("src")},q(t)),o.opts.imageManagerDeleteParams),crossDomain:o.opts.requestWithCORS,xhrFields:{withCredentials:o.opts.requestWithCredentials},headers:o.opts.requestHeaders}).done(function(e){o.events.trigger("imageManager.imageDeleted",[e]);var a=x(parseInt(t.parent().attr("class").match(/fr-image-(\d+)/)[1],10)+1);t.parent().remove(),E(a),g.find("#fr-modal-tags > a").each(function(){0===g.find('#fr-image-list [data-tag*="'+O(this).text()+'"]').length&&O(this).removeClass("fr-selected-tag").hide()}),H(),T(!0)}).fail(function(e){U(C,e.response||e.responseText)})):U(L))}function U(e,a){10<=e&&e<20?i.hide():20<=e&&e<30&&O(".fr-image-deleting").removeClass("fr-image-deleting"),o.events.trigger("imageManager.error",[{code:e,message:t[e]},a])}function F(){var e=l.find(".fr-modal-head-line").outerHeight(),a=d.outerHeight();l.toggleClass("fr-show-tags"),l.hasClass("fr-show-tags")?(l.css("height",e+a),d.find("a").css("opacity",1)):(l.css("height",e),d.find("a").css("opacity",0))}function H(){var e=d.find(".fr-selected-tag");0<e.length?(n.find("img").parent().show(),e.each(function(e,r){n.find("img").each(function(e,a){var t=O(a);k(t,r.text)||t.parent().hide()})})):n.find("img").parent().show(),E(x()),I()}function j(e){e.preventDefault();var a=O(e.currentTarget);a.toggleClass("fr-selected-tag"),o.opts.imageManagerToggleTags&&a.siblings("a").removeClass("fr-selected-tag"),H()}function k(e,a){for(var t=(e.attr("data-tag")||"").split(","),r=0;r<t.length;r++)if(t[r]==a)return!0;return!1}return t[e]="Image cannot be loaded from the passed link.",t[p]="Error during load images request.",t[v]="Missing imageManagerLoadURL option.",t[M]="Parsing load response failed.",t[w]="Missing image thumb.",t[b]="Missing image URL.",t[C]="Error during delete image request.",t[L]="Missing imageManagerDeleteURL option.",{require:["image"],_init:function(){if(!o.$wp&&"IMG"!=o.el.tagName)return!1},show:function(){if(!g){var e,a='<div class="fr-modal-head-line"><i class="fa fa-bars fr-modal-more fr-not-available" id="fr-modal-more-'+o.sid+'" title="'+o.language.translate("Tags")+'"></i><h4 data-text="true">'+o.language.translate("Manage Images")+"</h4></div>";a+='<div class="fr-modal-tags" id="fr-modal-tags"></div>',e=o.opts.imageManagerPreloader?'<img class="fr-preloader" id="fr-preloader" alt="'+o.language.translate("Loading")+'.." src="'+o.opts.imageManagerPreloader+'" style="display: none;">':'<span class="fr-preloader" id="fr-preloader" style="display: none;">'+o.language.translate("Loading")+"</span>",e+='<div class="fr-image-list" id="fr-image-list"></div>';var t=o.modals.create(h,a,e);g=t.$modal,l=t.$head,r=t.$body}g.data("current-image",o.image.get()),o.modals.show(h),i||(i=g.find("#fr-preloader"),n=g.find("#fr-image-list"),d=g.find("#fr-modal-tags"),c=y(),D(),l.css("height",l.find(".fr-modal-head-line").outerHeight()),o.events.$on(O(o.o_win),"resize",function(){T(!!s)}),o.helpers.isMobile()&&(o.events.bindClick(n,"div.fr-image-container",function(e){g.find(".fr-mobile-selected").removeClass("fr-mobile-selected"),O(e.currentTarget).addClass("fr-mobile-selected")}),g.on(o._mousedown,function(){g.find(".fr-mobile-selected").removeClass("fr-mobile-selected")})),o.events.bindClick(n,".fr-insert-img",S),o.events.bindClick(n,".fr-delete-img",R),g.on(o._mousedown+" "+o._mouseup,function(e){e.stopPropagation()}),g.on(o._mousedown,"*",function(){o.events.disableBlur()}),r.on("scroll",I),o.events.bindClick(g,"i#fr-modal-more-"+o.sid,F),o.events.bindClick(d,"a",j)),i.show(),n.find(".fr-list-column").empty(),o.opts.imageManagerLoadURL?O.ajax({url:o.opts.imageManagerLoadURL,method:o.opts.imageManagerLoadMethod,data:o.opts.imageManagerLoadParams,dataType:"json",crossDomain:o.opts.requestWithCORS,xhrFields:{withCredentials:o.opts.requestWithCredentials},headers:o.opts.requestHeaders}).done(function(e,a,t){o.events.trigger("imageManager.imagesLoaded",[e]),function(e,a){try{n.find(".fr-list-column").empty(),u=m=f=0,s=e,I()}catch(t){U(M,a)}}(e,t.response),i.hide()}).fail(function(){var e=this.xhr();U(p,e.response||e.responseText)}):U(v)},hide:function(){o.modals.hide(h)}}},!O.FE.PLUGINS.image)throw new Error("Image manager plugin requires image plugin.");O.FE.DEFAULTS.imageInsertButtons.push("imageManager"),O.FE.RegisterCommand("imageManager",{title:"Browse",undo:!1,focus:!1,modal:!0,callback:function(){this.imageManager.show()},plugin:"imageManager"}),O.FE.DefineIcon("imageManager",{NAME:"folder"}),O.FE.DefineIcon("imageManagerInsert",{NAME:"plus"}),O.FE.DefineIcon("imageManagerDelete",{NAME:"trash"})});
@@ -0,0 +1,94 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ (function (factory) {
8
+ if (typeof define === 'function' && define.amd) {
9
+ // AMD. Register as an anonymous module.
10
+ define(['jquery'], factory);
11
+ } else if (typeof module === 'object' && module.exports) {
12
+ // Node/CommonJS
13
+ module.exports = function( root, jQuery ) {
14
+ if ( jQuery === undefined ) {
15
+ // require('jQuery') returns a factory that requires window to
16
+ // build a jQuery instance, we normalize how we use modules
17
+ // that require this pattern but the window provided is a noop
18
+ // if it's defined (how jquery works)
19
+ if ( typeof window !== 'undefined' ) {
20
+ jQuery = require('jquery');
21
+ }
22
+ else {
23
+ jQuery = require('jquery')(root);
24
+ }
25
+ }
26
+ return factory(jQuery);
27
+ };
28
+ } else {
29
+ // Browser globals
30
+ factory(window.jQuery);
31
+ }
32
+ }(function ($) {
33
+
34
+
35
+
36
+ $.extend($.FE.DEFAULTS, {
37
+ inlineStyles: {
38
+ 'Big Red': 'font-size: 20px; color: red;',
39
+ 'Small Blue': 'font-size: 14px; color: blue;'
40
+ }
41
+ })
42
+
43
+ $.FE.PLUGINS.inlineStyle = function (editor) {
44
+ function apply (val) {
45
+ if (editor.selection.text() !== '') {
46
+ var splits = val.split(';');
47
+
48
+ for (var i = 0; i < splits.length; i++) {
49
+ var new_split = splits[i].split(':');
50
+
51
+ if (splits[i].length && new_split.length == 2) {
52
+ editor.format.applyStyle(new_split[0].trim(), new_split[1].trim())
53
+ }
54
+ }
55
+ }
56
+ else {
57
+ editor.html.insert('<span style="' + val + '">' + $.FE.INVISIBLE_SPACE + $.FE.MARKERS + '</span>');
58
+ }
59
+ }
60
+
61
+ return {
62
+ apply: apply
63
+ }
64
+ }
65
+
66
+ // Register the inline style command.
67
+ $.FE.RegisterCommand('inlineStyle', {
68
+ type: 'dropdown',
69
+ html: function () {
70
+ var c = '<ul class="fr-dropdown-list" role="presentation">';
71
+ var options = this.opts.inlineStyles;
72
+
73
+ for (var val in options) {
74
+ if (options.hasOwnProperty(val)) {
75
+ c += '<li role="presentation"><span style="' + options[val] + '" role="presentation"><a class="fr-command" tabIndex="-1" role="option" data-cmd="inlineStyle" data-param1="' + options[val] + '" title="' + this.language.translate(val) + '">' + this.language.translate(val) + '</a></span></li>';
76
+ }
77
+ }
78
+ c += '</ul>';
79
+
80
+ return c;
81
+ },
82
+ title: 'Inline Style',
83
+ callback: function (cmd, val) {
84
+ this.inlineStyle.apply(val);
85
+ },
86
+ plugin: 'inlineStyle'
87
+ })
88
+
89
+ // Add the font size icon.
90
+ $.FE.DefineIcon('inlineStyle', {
91
+ NAME: 'paint-brush'
92
+ });
93
+
94
+ }));
@@ -0,0 +1,7 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ !function(t){"function"==typeof define&&define.amd?define(["jquery"],t):"object"==typeof module&&module.exports?module.exports=function(e,n){return n===undefined&&(n="undefined"!=typeof window?require("jquery"):require("jquery")(e)),t(n)}:t(window.jQuery)}(function(r){r.extend(r.FE.DEFAULTS,{inlineStyles:{"Big Red":"font-size: 20px; color: red;","Small Blue":"font-size: 14px; color: blue;"}}),r.FE.PLUGINS.inlineStyle=function(l){return{apply:function(e){if(""!==l.selection.text())for(var n=e.split(";"),t=0;t<n.length;t++){var i=n[t].split(":");n[t].length&&2==i.length&&l.format.applyStyle(i[0].trim(),i[1].trim())}else l.html.insert('<span style="'+e+'">'+r.FE.INVISIBLE_SPACE+r.FE.MARKERS+"</span>")}}},r.FE.RegisterCommand("inlineStyle",{type:"dropdown",html:function(){var e='<ul class="fr-dropdown-list" role="presentation">',n=this.opts.inlineStyles;for(var t in n)n.hasOwnProperty(t)&&(e+='<li role="presentation"><span style="'+n[t]+'" role="presentation"><a class="fr-command" tabIndex="-1" role="option" data-cmd="inlineStyle" data-param1="'+n[t]+'" title="'+this.language.translate(t)+'">'+this.language.translate(t)+"</a></span></li>");return e+="</ul>"},title:"Inline Style",callback:function(e,n){this.inlineStyle.apply(n)},plugin:"inlineStyle"}),r.FE.DefineIcon("inlineStyle",{NAME:"paint-brush"})});
@@ -0,0 +1,537 @@
1
+ /*!
2
+ * froala_editor v2.8.1 (https://www.froala.com/wysiwyg-editor)
3
+ * License https://froala.com/wysiwyg-editor/terms/
4
+ * Copyright 2014-2018 Froala Labs
5
+ */
6
+
7
+ (function (factory) {
8
+ if (typeof define === 'function' && define.amd) {
9
+ // AMD. Register as an anonymous module.
10
+ define(['jquery'], factory);
11
+ } else if (typeof module === 'object' && module.exports) {
12
+ // Node/CommonJS
13
+ module.exports = function( root, jQuery ) {
14
+ if ( jQuery === undefined ) {
15
+ // require('jQuery') returns a factory that requires window to
16
+ // build a jQuery instance, we normalize how we use modules
17
+ // that require this pattern but the window provided is a noop
18
+ // if it's defined (how jquery works)
19
+ if ( typeof window !== 'undefined' ) {
20
+ jQuery = require('jquery');
21
+ }
22
+ else {
23
+ jQuery = require('jquery')(root);
24
+ }
25
+ }
26
+ return factory(jQuery);
27
+ };
28
+ } else {
29
+ // Browser globals
30
+ factory(window.jQuery);
31
+ }
32
+ }(function ($) {
33
+
34
+
35
+
36
+ // Extend defaults.
37
+ $.extend($.FE.DEFAULTS, {
38
+ lineBreakerTags: ['table', 'hr', 'form', 'dl', 'span.fr-video', '.fr-embedly'],
39
+ lineBreakerOffset: 15,
40
+ lineBreakerHorizontalOffset: 10
41
+ });
42
+
43
+ $.FE.PLUGINS.lineBreaker = function (editor) {
44
+ var $line_breaker;
45
+ var mouseDownFlag;
46
+ var mouseMoveTimer;
47
+
48
+ /*
49
+ * Show line breaker.
50
+ * Compute top, left, width and show the line breaker.
51
+ * tag1 and tag2 are the tags between which the line breaker must be showed.
52
+ * If tag1 is null then tag2 is the first tag in the editor.
53
+ * If tag2 is null then tag1 is the last tag in the editor.
54
+ */
55
+ function _show($tag1, $tag2) {
56
+
57
+ // Line breaker's possition and width.
58
+ var breakerTop;
59
+ var breakerLeft;
60
+ var breakerWidth;
61
+ var parent_tag;
62
+ var parent_top;
63
+ var parent_bottom;
64
+ var tag_top;
65
+ var tag_bottom;
66
+
67
+ // Mouse is over the first tag in the editor. Show line breaker above tag2.
68
+ if ($tag1 == null) {
69
+ // Compute line breaker's possition and width.
70
+ parent_tag = $tag2.parent();
71
+ parent_top = parent_tag.offset().top;
72
+ tag_top = $tag2.offset().top;
73
+
74
+ breakerTop = tag_top - Math.min((tag_top - parent_top) / 2, editor.opts.lineBreakerOffset);
75
+ breakerWidth = parent_tag.outerWidth();
76
+ breakerLeft = parent_tag.offset().left;
77
+ }
78
+
79
+ // Mouse is over the last tag in the editor. Show line breaker below tag1.
80
+ else if ($tag2 == null) {
81
+ // Compute line breaker's possition and width.
82
+ parent_tag = $tag1.parent();
83
+ parent_bottom = parent_tag.offset().top + parent_tag.outerHeight();
84
+ tag_bottom = $tag1.offset().top + $tag1.outerHeight();
85
+
86
+ if (parent_bottom < tag_bottom) {
87
+ parent_tag = $(parent_tag).parent();
88
+ parent_bottom = parent_tag.offset().top + parent_tag.outerHeight();
89
+ }
90
+
91
+ breakerTop = tag_bottom + Math.min(Math.abs(parent_bottom - tag_bottom) / 2, editor.opts.lineBreakerOffset);
92
+ breakerWidth = parent_tag.outerWidth();
93
+ breakerLeft = parent_tag.offset().left;
94
+ }
95
+
96
+ // Mouse is between the 2 tags.
97
+ else {
98
+ // Compute line breaker's possition and width.
99
+ parent_tag = $tag1.parent();
100
+ var tag1_bottom = $tag1.offset().top + $tag1.height();
101
+ var tag2_top = $tag2.offset().top;
102
+
103
+ // Tags may be on the same line, so there is no need for line breaker.
104
+ if (tag1_bottom > tag2_top) {
105
+ return false;
106
+ }
107
+
108
+ breakerTop = (tag1_bottom + tag2_top) / 2;
109
+ breakerWidth = parent_tag.outerWidth();
110
+ breakerLeft = parent_tag.offset().left;
111
+ }
112
+
113
+ if (editor.opts.iframe) {
114
+ breakerLeft += editor.$iframe.offset().left - editor.helpers.scrollLeft();
115
+ breakerTop += editor.$iframe.offset().top - editor.helpers.scrollTop();
116
+ }
117
+
118
+ editor.$box.append($line_breaker);
119
+
120
+ // Set line breaker's top, left and width.
121
+ $line_breaker.css('top', breakerTop - editor.win.pageYOffset);
122
+ $line_breaker.css('left', breakerLeft - editor.win.pageXOffset);
123
+ $line_breaker.css('width', breakerWidth);
124
+ $line_breaker.data('tag1', $tag1);
125
+ $line_breaker.data('tag2', $tag2);
126
+
127
+ // Show the line breaker.
128
+ $line_breaker.addClass('fr-visible').data('instance', editor);
129
+ }
130
+
131
+ /*
132
+ * Check tag siblings.
133
+ * The line breaker hould appear if there is no sibling or if the sibling is also in the line breaker tags list.
134
+ */
135
+ function _checkTagSiblings($tag, mouseY) {
136
+
137
+ // Tag's Y top and bottom coordinate.
138
+ var tag_top = $tag.offset().top;
139
+ var tag_bottom = $tag.offset().top + $tag.outerHeight();
140
+ var $sibling;
141
+ var tag;
142
+
143
+ // Only if the mouse is close enough to the bottom or top edges.
144
+ if (Math.abs(tag_bottom - mouseY) <= editor.opts.lineBreakerOffset ||
145
+ Math.abs(mouseY - tag_top) <= editor.opts.lineBreakerOffset) {
146
+
147
+ // Mouse is near bottom check for next sibling.
148
+ if (Math.abs(tag_bottom - mouseY) < Math.abs(mouseY - tag_top)) {
149
+ tag = $tag.get(0);
150
+ var next_node = tag.nextSibling;
151
+
152
+ while (next_node && next_node.nodeType == Node.TEXT_NODE && next_node.textContent.length === 0) {
153
+ next_node = next_node.nextSibling;
154
+ }
155
+
156
+ // Tag has next sibling.
157
+ if (next_node) {
158
+ $sibling = _checkTag(next_node);
159
+
160
+ // Sibling is in the line breaker tags list.
161
+ if ($sibling) {
162
+
163
+ // Show line breaker.
164
+ _show($tag, $sibling);
165
+
166
+ return true;
167
+ }
168
+
169
+ // No next sibling.
170
+ }
171
+ else {
172
+
173
+ // Show line breaker
174
+ _show($tag, null);
175
+
176
+ return true;
177
+ }
178
+ }
179
+
180
+ // Mouse is near top check for prev sibling.
181
+ else {
182
+ tag = $tag.get(0);
183
+
184
+ // No prev sibling.
185
+ if (!tag.previousSibling) {
186
+
187
+ // Show line breaker
188
+ _show(null, $tag);
189
+
190
+ return true;
191
+
192
+ // Tag has prev sibling.
193
+ }
194
+ else {
195
+ $sibling = _checkTag(tag.previousSibling);
196
+
197
+ // Sibling is in the line breaker tags list.
198
+ if ($sibling) {
199
+
200
+ // Show line breaker.
201
+ _show($sibling, $tag);
202
+
203
+ return true;
204
+ }
205
+ }
206
+ }
207
+ }
208
+
209
+ $line_breaker.removeClass('fr-visible').removeData('instance');
210
+ }
211
+
212
+ /*
213
+ * Check if tag is in the line breaker list and in the editor as well.
214
+ * Returns the tag from the line breaker list or false if the tag is not in the list.
215
+ */
216
+ function _checkTag(tag) {
217
+ if (tag) {
218
+ var $tag = $(tag);
219
+
220
+ // Make sure tag is inside the editor.
221
+ if (editor.$el.find($tag).length === 0) return null;
222
+
223
+ // Tag is in the line breaker tags list.
224
+ if (tag.nodeType != Node.TEXT_NODE && $tag.is(editor.opts.lineBreakerTags.join(','))) {
225
+
226
+ return $tag;
227
+ }
228
+
229
+ // Tag's parent is in the line breaker tags list.
230
+ else if ($tag.parents(editor.opts.lineBreakerTags.join(',')).length > 0) {
231
+ tag = $tag.parents(editor.opts.lineBreakerTags.join(',')).get(0);
232
+
233
+ if (editor.$el.find(tag).length === 0 || !$(tag).is(editor.opts.lineBreakerTags.join(','))) return null;
234
+
235
+ return $(tag);
236
+ }
237
+ }
238
+
239
+ return null;
240
+ }
241
+
242
+ function _isInWp(tag) {
243
+ if (typeof tag.inFroalaWrapper != 'undefined') return tag.inFroalaWrapper;
244
+ var o_tag = tag;
245
+
246
+ while (tag.parentNode && tag.parentNode !== editor.$wp.get(0)) {
247
+ tag = tag.parentNode;
248
+ }
249
+
250
+ o_tag.inFroalaWrapper = (tag.parentNode == editor.$wp.get(0));
251
+
252
+ return o_tag.inFroalaWrapper;
253
+ }
254
+
255
+ /*
256
+ * Look for tag at the specified coordinates.
257
+ */
258
+ function _tagAt(x, y) {
259
+ var tag = editor.doc.elementFromPoint(x, y);
260
+
261
+ // We found a tag.
262
+ if (tag && !$(tag).closest('.fr-line-breaker').length && !editor.node.isElement(tag) && tag != editor.$wp.get(0) && _isInWp(tag)) {
263
+ return tag;
264
+ }
265
+
266
+ // No tag at x, y.
267
+ return null;
268
+ }
269
+
270
+ /*
271
+ * Look for tags above and bellow the specificed point.
272
+ */
273
+ function _searchTagVertically(x, y, step) {
274
+ var i = step;
275
+ var tag = null;
276
+
277
+ // Look up and down until a tag is found or the line breaker offset is reached.
278
+ while (i <= editor.opts.lineBreakerOffset && !tag) {
279
+
280
+ // Look for tag above.
281
+ tag = _tagAt(x, y - i);
282
+
283
+ if (!tag) {
284
+
285
+ // Look for tag below.
286
+ tag = _tagAt(x, y + i);
287
+ }
288
+
289
+ i += step;
290
+ }
291
+
292
+ return tag;
293
+ }
294
+
295
+ /*
296
+ * Look for tag left and right, up and down for each point.
297
+ */
298
+ function _searchTagHorizontally(x, y, direction) {
299
+ var tag = null;
300
+
301
+ // Do not check left / right too much.
302
+ var limit = 100;
303
+
304
+ // Look left / right until a tag is found or the editor margins are reached.
305
+ while (!tag && x > editor.$box.offset().left && x < editor.$box.offset().left + editor.$box.outerWidth() && limit > 0) {
306
+ tag = _tagAt(x, y);
307
+
308
+ // There's not tag here, look up and down.
309
+ if (!tag) {
310
+
311
+ // Look 5px up and 5 down.
312
+ tag = _searchTagVertically(x, y, 5);
313
+ }
314
+
315
+ // Move left or right.
316
+ if (direction == 'left') x -= editor.opts.lineBreakerHorizontalOffset;
317
+ else x += editor.opts.lineBreakerHorizontalOffset;
318
+
319
+ limit -= editor.opts.lineBreakerHorizontalOffset;
320
+ }
321
+
322
+ return tag;
323
+ }
324
+
325
+ /*
326
+ * Get the tag under the mouse cursor.
327
+ */
328
+ function _tagUnder(e) {
329
+ mouseMoveTimer = null;
330
+
331
+ // The tag for which the line breaker should be showed.
332
+ var $tag = null;
333
+ var tag = null;
334
+
335
+ // The tag under the mouse cursor.
336
+ var tag_under = editor.doc.elementFromPoint(e.pageX - editor.win.pageXOffset, e.pageY - editor.win.pageYOffset);
337
+
338
+ // Tag is the editor element. Look for closest tag above and bellow, left and right.
339
+ if (tag_under && (tag_under.tagName == 'HTML' || tag_under.tagName == 'BODY' || editor.node.isElement(tag_under) || (tag_under.getAttribute('class') || '').indexOf('fr-line-breaker') >= 0)) {
340
+
341
+ // Look 1px up and 1 down.
342
+ tag = _searchTagVertically(e.pageX - editor.win.pageXOffset, e.pageY - editor.win.pageYOffset, 1);
343
+
344
+ // Stil haven't found a tag, look left.
345
+ if (!tag) {
346
+ tag = _searchTagHorizontally(e.pageX - editor.win.pageXOffset - editor.opts.lineBreakerHorizontalOffset, e.pageY - editor.win.pageYOffset, 'left');
347
+ }
348
+
349
+ // Stil haven't found a tag, look right.
350
+ if (!tag) {
351
+ tag = _searchTagHorizontally(e.pageX - editor.win.pageXOffset + editor.opts.lineBreakerHorizontalOffset, e.pageY - editor.win.pageYOffset, 'right');
352
+ }
353
+
354
+ $tag = _checkTag(tag);
355
+
356
+ // Tag is not the editor element.
357
+ }
358
+ else {
359
+
360
+ // Check if the tag is in the line breaker list.
361
+ $tag = _checkTag(tag_under);
362
+ }
363
+
364
+ // Check tag siblings.
365
+ if ($tag) {
366
+ _checkTagSiblings($tag, e.pageY);
367
+ }
368
+ else if (editor.core.sameInstance($line_breaker)) {
369
+ $line_breaker.removeClass('fr-visible').removeData('instance');
370
+ }
371
+ }
372
+
373
+ /*
374
+ * Set mouse timer to improve performance.
375
+ */
376
+ function _mouseTimer(e) {
377
+ if ($line_breaker.hasClass('fr-visible') && !editor.core.sameInstance($line_breaker)) return false;
378
+
379
+ if (editor.popups.areVisible() || editor.el.querySelector('.fr-selected-cell')) {
380
+ $line_breaker.removeClass('fr-visible');
381
+
382
+ return true;
383
+ }
384
+
385
+ if (mouseDownFlag === false && !editor.edit.isDisabled()) {
386
+ if (mouseMoveTimer) {
387
+ clearTimeout(mouseMoveTimer);
388
+ }
389
+
390
+ mouseMoveTimer = setTimeout(_tagUnder, 30, e);
391
+ }
392
+ }
393
+
394
+ /*
395
+ * Hide line breaker and prevent timer from showing it again.
396
+ */
397
+ function _hide() {
398
+ if (mouseMoveTimer) {
399
+ clearTimeout(mouseMoveTimer);
400
+ }
401
+
402
+ if ($line_breaker.hasClass('fr-visible')) {
403
+ $line_breaker.removeClass('fr-visible').removeData('instance');
404
+ }
405
+ }
406
+
407
+ /*
408
+ * Notify that mouse is down and prevent line breaker from showing.
409
+ * This may happen either for selection or for drag.
410
+ */
411
+ function _mouseDown() {
412
+ mouseDownFlag = true;
413
+ _hide();
414
+ }
415
+
416
+ /*
417
+ * Notify that mouse is no longer pressed.
418
+ */
419
+ function _mouseUp() {
420
+ mouseDownFlag = false;
421
+ }
422
+
423
+ /*
424
+ * Add new line between the tags.
425
+ */
426
+ function _doLineBreak(e) {
427
+ e.preventDefault();
428
+
429
+ var instance = $line_breaker.data('instance') || editor;
430
+
431
+ // Hide the line breaker.
432
+ $line_breaker.removeClass('fr-visible').removeData('instance');
433
+
434
+ // Tags between which that line break needs to be done.
435
+ var $tag1 = $line_breaker.data('tag1');
436
+ var $tag2 = $line_breaker.data('tag2');
437
+
438
+ // P, DIV or none.
439
+ var default_tag = editor.html.defaultTag();
440
+
441
+ // The line break needs to be done before the first element in the editor.
442
+ if ($tag1 == null) {
443
+
444
+ // If the tag is in a TD tag then just add <br> no matter what the default_tag is.
445
+ if (default_tag && $tag2.parent().get(0).tagName != 'TD' && $tag2.parents(default_tag).length === 0) {
446
+ $tag2.before('<' + default_tag + '>' + $.FE.MARKERS + '<br></' + default_tag + '>')
447
+ }
448
+ else {
449
+ $tag2.before($.FE.MARKERS + '<br>');
450
+ }
451
+
452
+ // The line break needs to be done either after the last element in the editor or between the 2 tags.
453
+ // Either way the line break is after the first tag.
454
+ }
455
+ else {
456
+
457
+ // If the tag is in a TD tag then just add <br> no matter what the default_tag is.
458
+ if (default_tag && $tag1.parent().get(0).tagName != 'TD' && $tag1.parents(default_tag).length === 0) {
459
+ $tag1.after('<' + default_tag + '>' + $.FE.MARKERS + '<br></' + default_tag + '>')
460
+ }
461
+ else {
462
+ $tag1.after($.FE.MARKERS + '<br>');
463
+ }
464
+ }
465
+
466
+ // Cursor is now at the beginning of the new line.
467
+ instance.selection.restore();
468
+ }
469
+
470
+ /*
471
+ * Initialize the line breaker.
472
+ */
473
+ function _initLineBreaker() {
474
+
475
+ // Append line breaker HTML to editor wrapper.
476
+ if (!editor.shared.$line_breaker) {
477
+ editor.shared.$line_breaker = $('<div class="fr-line-breaker"><a class="fr-floating-btn" role="button" tabIndex="-1" title="' + editor.language.translate('Break') + '"><svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32"><rect x="21" y="11" width="2" height="8"/><rect x="14" y="17" width="7" height="2"/><path d="M14.000,14.000 L14.000,22.013 L9.000,18.031 L14.000,14.000 Z"/></svg></a></div>');
478
+ }
479
+
480
+ $line_breaker = editor.shared.$line_breaker;
481
+
482
+ // Editor shared destroy.
483
+ editor.events.on('shared.destroy', function () {
484
+ $line_breaker.html('').removeData().remove();
485
+ $line_breaker = null;
486
+ }, true);
487
+
488
+ // Editor destroy.
489
+ editor.events.on('destroy', function () {
490
+ $line_breaker.removeData('instance').removeClass('fr-visible').appendTo('body:first');
491
+ clearTimeout(mouseMoveTimer);
492
+ }, true)
493
+
494
+ editor.events.$on($line_breaker, 'mousemove', function (e) {
495
+ e.stopPropagation();
496
+ }, true)
497
+
498
+ // Add new line break.
499
+ editor.events.bindClick($line_breaker, 'a', _doLineBreak);
500
+ }
501
+
502
+ /*
503
+ * Tear up.
504
+ */
505
+ function _init() {
506
+ if (!editor.$wp) return false;
507
+
508
+ _initLineBreaker();
509
+
510
+ // Remember if mouse is clicked so the line breaker does not appear.
511
+ mouseDownFlag = false;
512
+
513
+ // Check tags under the mouse to see if the line breaker needs to be shown.
514
+ editor.events.$on(editor.$win, 'mousemove', _mouseTimer);
515
+
516
+ // Hide the line breaker if the page is scrolled.
517
+ editor.events.$on($(editor.win), 'scroll', _hide);
518
+
519
+ // Hide the line breaker on cell edit.
520
+ editor.events.on('popups.show.table.edit', _hide);
521
+
522
+ // Hide the line breaker after command is ran.
523
+ editor.events.on('commands.after', _hide);
524
+
525
+ // Prevent line breaker from showing while selecting text or dragging images.
526
+ editor.events.$on($(editor.win), 'mousedown', _mouseDown);
527
+
528
+ // Mouse is not pressed anymore, line breaker may be shown.
529
+ editor.events.$on($(editor.win), 'mouseup', _mouseUp);
530
+ }
531
+
532
+ return {
533
+ _init: _init
534
+ }
535
+ };
536
+
537
+ }));