editable_components 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (188) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +64 -0
  4. data/Rakefile +34 -0
  5. data/app/assets/config/editable_components_manifest.js +2 -0
  6. data/app/assets/fonts/editable_components/icomoon.eot +0 -0
  7. data/app/assets/fonts/editable_components/icomoon.svg +24 -0
  8. data/app/assets/fonts/editable_components/icomoon.ttf +0 -0
  9. data/app/assets/fonts/editable_components/icomoon.woff +0 -0
  10. data/app/assets/javascripts/editable_components/application.js +13 -0
  11. data/app/assets/javascripts/editable_components/dragula/dragula.css +22 -0
  12. data/app/assets/javascripts/editable_components/dragula/dragula.js +908 -0
  13. data/app/assets/javascripts/editable_components/dragula/dragula.min.css +1 -0
  14. data/app/assets/javascripts/editable_components/dragula/dragula.min.js +1 -0
  15. data/app/assets/javascripts/editable_components/dropzone/CONTRIBUTING.md +78 -0
  16. data/app/assets/javascripts/editable_components/dropzone/LICENSE +12 -0
  17. data/app/assets/javascripts/editable_components/dropzone/README.md +134 -0
  18. data/app/assets/javascripts/editable_components/dropzone/basic.css +39 -0
  19. data/app/assets/javascripts/editable_components/dropzone/dropzone-amd-module.js +1782 -0
  20. data/app/assets/javascripts/editable_components/dropzone/dropzone.css +388 -0
  21. data/app/assets/javascripts/editable_components/dropzone/dropzone.js +1767 -0
  22. data/app/assets/javascripts/editable_components/dropzone/min/basic.min.css +1 -0
  23. data/app/assets/javascripts/editable_components/dropzone/min/dropzone-amd-module.min.js +2 -0
  24. data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.css +1 -0
  25. data/app/assets/javascripts/editable_components/dropzone/min/dropzone.min.js +2 -0
  26. data/app/assets/javascripts/editable_components/main.js +280 -0
  27. data/app/assets/javascripts/editable_components/medium-editor/API.md +520 -0
  28. data/app/assets/javascripts/editable_components/medium-editor/CHANGES.md +1043 -0
  29. data/app/assets/javascripts/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
  30. data/app/assets/javascripts/editable_components/medium-editor/CONTRIBUTING.md +56 -0
  31. data/app/assets/javascripts/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
  32. data/app/assets/javascripts/editable_components/medium-editor/LICENSE +36 -0
  33. data/app/assets/javascripts/editable_components/medium-editor/MAINTAINERS.md +33 -0
  34. data/app/assets/javascripts/editable_components/medium-editor/OPTIONS.md +663 -0
  35. data/app/assets/javascripts/editable_components/medium-editor/README.md +725 -0
  36. data/app/assets/javascripts/editable_components/medium-editor/UPGRADE-5.md +146 -0
  37. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.css +230 -0
  38. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.js +7876 -0
  39. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.css +1 -0
  40. data/app/assets/javascripts/editable_components/medium-editor/medium-editor.min.js +4 -0
  41. data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.css +78 -0
  42. data/app/assets/javascripts/editable_components/medium-editor/themes/beagle.min.css +1 -0
  43. data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.css +67 -0
  44. data/app/assets/javascripts/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
  45. data/app/assets/javascripts/editable_components/medium-editor/themes/default.css +63 -0
  46. data/app/assets/javascripts/editable_components/medium-editor/themes/default.min.css +1 -0
  47. data/app/assets/javascripts/editable_components/medium-editor/themes/flat.css +58 -0
  48. data/app/assets/javascripts/editable_components/medium-editor/themes/flat.min.css +1 -0
  49. data/app/assets/javascripts/editable_components/medium-editor/themes/mani.css +57 -0
  50. data/app/assets/javascripts/editable_components/medium-editor/themes/mani.min.css +1 -0
  51. data/app/assets/javascripts/editable_components/medium-editor/themes/roman.css +58 -0
  52. data/app/assets/javascripts/editable_components/medium-editor/themes/roman.min.css +1 -0
  53. data/app/assets/javascripts/editable_components/medium-editor/themes/tim.css +67 -0
  54. data/app/assets/javascripts/editable_components/medium-editor/themes/tim.min.css +1 -0
  55. data/app/assets/javascripts/editable_components/sizzle/sizzle.js +2272 -0
  56. data/app/assets/javascripts/editable_components/sizzle/sizzle.min.js +3 -0
  57. data/app/assets/javascripts/editable_components/sizzle/sizzle.min.map +1 -0
  58. data/app/assets/javascripts/editable_components/vue/README.md +124 -0
  59. data/app/assets/javascripts/editable_components/vue/vue.common.js +9320 -0
  60. data/app/assets/javascripts/editable_components/vue/vue.common.min.js +7 -0
  61. data/app/assets/javascripts/editable_components/vue/vue.esm.js +9318 -0
  62. data/app/assets/javascripts/editable_components/vue/vue.js +9316 -0
  63. data/app/assets/javascripts/editable_components/vue/vue.min.js +8 -0
  64. data/app/assets/javascripts/editable_components/vue/vue.runtime.common.js +6831 -0
  65. data/app/assets/javascripts/editable_components/vue/vue.runtime.esm.js +6829 -0
  66. data/app/assets/javascripts/editable_components/vue/vue.runtime.js +6827 -0
  67. data/app/assets/javascripts/editable_components/vue/vue.runtime.min.js +7 -0
  68. data/app/assets/stylesheets/editable_components/application.sass +65 -0
  69. data/app/assets/stylesheets/editable_components/blaze/blaze.colors.min.css +1 -0
  70. data/app/assets/stylesheets/editable_components/blaze/blaze.min.css +1 -0
  71. data/app/assets/stylesheets/editable_components/blaze/components.addresses.min.css +1 -0
  72. data/app/assets/stylesheets/editable_components/blaze/components.alerts.min.css +1 -0
  73. data/app/assets/stylesheets/editable_components/blaze/components.avatars.min.css +1 -0
  74. data/app/assets/stylesheets/editable_components/blaze/components.badges.min.css +1 -0
  75. data/app/assets/stylesheets/editable_components/blaze/components.breadcrumbs.min.css +1 -0
  76. data/app/assets/stylesheets/editable_components/blaze/components.bubbles.min.css +1 -0
  77. data/app/assets/stylesheets/editable_components/blaze/components.buttons.min.css +1 -0
  78. data/app/assets/stylesheets/editable_components/blaze/components.calendars.min.css +1 -0
  79. data/app/assets/stylesheets/editable_components/blaze/components.cards.min.css +1 -0
  80. data/app/assets/stylesheets/editable_components/blaze/components.headings.min.css +1 -0
  81. data/app/assets/stylesheets/editable_components/blaze/components.hints.min.css +1 -0
  82. data/app/assets/stylesheets/editable_components/blaze/components.input-groups.min.css +1 -0
  83. data/app/assets/stylesheets/editable_components/blaze/components.inputs.min.css +1 -0
  84. data/app/assets/stylesheets/editable_components/blaze/components.links.min.css +1 -0
  85. data/app/assets/stylesheets/editable_components/blaze/components.lists.min.css +1 -0
  86. data/app/assets/stylesheets/editable_components/blaze/components.navs.min.css +1 -0
  87. data/app/assets/stylesheets/editable_components/blaze/components.overlays.min.css +1 -0
  88. data/app/assets/stylesheets/editable_components/blaze/components.pagination.min.css +1 -0
  89. data/app/assets/stylesheets/editable_components/blaze/components.progress.min.css +1 -0
  90. data/app/assets/stylesheets/editable_components/blaze/components.ranges.min.css +1 -0
  91. data/app/assets/stylesheets/editable_components/blaze/components.tables.min.css +1 -0
  92. data/app/assets/stylesheets/editable_components/blaze/components.tabs.min.css +1 -0
  93. data/app/assets/stylesheets/editable_components/blaze/components.tags.min.css +1 -0
  94. data/app/assets/stylesheets/editable_components/blaze/components.toggles.min.css +1 -0
  95. data/app/assets/stylesheets/editable_components/blaze/components.tooltips.min.css +1 -0
  96. data/app/assets/stylesheets/editable_components/blaze/components.trees.min.css +1 -0
  97. data/app/assets/stylesheets/editable_components/blaze/components.typography.min.css +1 -0
  98. data/app/assets/stylesheets/editable_components/blaze/generics.global.min.css +1 -0
  99. data/app/assets/stylesheets/editable_components/blaze/objects.containers.min.css +1 -0
  100. data/app/assets/stylesheets/editable_components/blaze/objects.drawers.min.css +1 -0
  101. data/app/assets/stylesheets/editable_components/blaze/objects.forms.min.css +1 -0
  102. data/app/assets/stylesheets/editable_components/blaze/objects.grid.min.css +1 -0
  103. data/app/assets/stylesheets/editable_components/blaze/objects.grid.responsive.min.css +1 -0
  104. data/app/assets/stylesheets/editable_components/blaze/objects.images.min.css +1 -0
  105. data/app/assets/stylesheets/editable_components/blaze/objects.media.min.css +1 -0
  106. data/app/assets/stylesheets/editable_components/blaze/objects.modals.min.css +1 -0
  107. data/app/assets/stylesheets/editable_components/blaze/objects.panels.min.css +1 -0
  108. data/app/assets/stylesheets/editable_components/blaze/themes/blaze.example.min.css +1 -0
  109. data/app/assets/stylesheets/editable_components/blaze/utilities.alignment.min.css +1 -0
  110. data/app/assets/stylesheets/editable_components/blaze/utilities.boxing.min.css +1 -0
  111. data/app/assets/stylesheets/editable_components/blaze/utilities.elevation.min.css +1 -0
  112. data/app/assets/stylesheets/editable_components/blaze/utilities.sizes.min.css +1 -0
  113. data/app/assets/stylesheets/editable_components/dragula/dragula.css +22 -0
  114. data/app/assets/stylesheets/editable_components/dragula/dragula.js +908 -0
  115. data/app/assets/stylesheets/editable_components/dragula/dragula.min.css +1 -0
  116. data/app/assets/stylesheets/editable_components/dragula/dragula.min.js +1 -0
  117. data/app/assets/stylesheets/editable_components/main.sass +225 -0
  118. data/app/assets/stylesheets/editable_components/medium-editor/API.md +520 -0
  119. data/app/assets/stylesheets/editable_components/medium-editor/CHANGES.md +1043 -0
  120. data/app/assets/stylesheets/editable_components/medium-editor/CODE_OF_CONDUCT.md +13 -0
  121. data/app/assets/stylesheets/editable_components/medium-editor/CONTRIBUTING.md +56 -0
  122. data/app/assets/stylesheets/editable_components/medium-editor/CUSTOM-EVENTS.md +223 -0
  123. data/app/assets/stylesheets/editable_components/medium-editor/LICENSE +36 -0
  124. data/app/assets/stylesheets/editable_components/medium-editor/MAINTAINERS.md +33 -0
  125. data/app/assets/stylesheets/editable_components/medium-editor/OPTIONS.md +663 -0
  126. data/app/assets/stylesheets/editable_components/medium-editor/README.md +725 -0
  127. data/app/assets/stylesheets/editable_components/medium-editor/UPGRADE-5.md +146 -0
  128. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.css +230 -0
  129. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.js +7876 -0
  130. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.css +1 -0
  131. data/app/assets/stylesheets/editable_components/medium-editor/medium-editor.min.js +4 -0
  132. data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.css +78 -0
  133. data/app/assets/stylesheets/editable_components/medium-editor/themes/beagle.min.css +1 -0
  134. data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.css +67 -0
  135. data/app/assets/stylesheets/editable_components/medium-editor/themes/bootstrap.min.css +1 -0
  136. data/app/assets/stylesheets/editable_components/medium-editor/themes/default.css +63 -0
  137. data/app/assets/stylesheets/editable_components/medium-editor/themes/default.min.css +1 -0
  138. data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.css +58 -0
  139. data/app/assets/stylesheets/editable_components/medium-editor/themes/flat.min.css +1 -0
  140. data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.css +57 -0
  141. data/app/assets/stylesheets/editable_components/medium-editor/themes/mani.min.css +1 -0
  142. data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.css +58 -0
  143. data/app/assets/stylesheets/editable_components/medium-editor/themes/roman.min.css +1 -0
  144. data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.css +67 -0
  145. data/app/assets/stylesheets/editable_components/medium-editor/themes/tim.min.css +1 -0
  146. data/app/controllers/editable_components/blocks_controller.rb +36 -0
  147. data/app/helpers/editable_components/application_helper.rb +4 -0
  148. data/app/jobs/editable_components/application_job.rb +4 -0
  149. data/app/mailers/editable_components/application_mailer.rb +6 -0
  150. data/app/models/editable_components/application_record.rb +5 -0
  151. data/app/models/editable_components/block.rb +176 -0
  152. data/app/models/editable_components/concerns/editable.rb +34 -0
  153. data/app/models/editable_components/item.rb +50 -0
  154. data/app/models/editable_components/item_boolean.rb +23 -0
  155. data/app/models/editable_components/item_datetime.rb +14 -0
  156. data/app/models/editable_components/item_file.rb +46 -0
  157. data/app/models/editable_components/item_float.rb +23 -0
  158. data/app/models/editable_components/item_hash.rb +16 -0
  159. data/app/models/editable_components/item_integer.rb +23 -0
  160. data/app/models/editable_components/item_string.rb +29 -0
  161. data/app/models/editable_components/item_text.rb +19 -0
  162. data/app/views/editable_components/_admin_toolbar.html.erb +105 -0
  163. data/app/views/editable_components/_block.html.erb +6 -0
  164. data/app/views/editable_components/_block_image.html.erb +6 -0
  165. data/app/views/editable_components/_block_multi_text.html.erb +7 -0
  166. data/app/views/editable_components/_block_slide.html.erb +6 -0
  167. data/app/views/editable_components/_block_slider.html.erb +7 -0
  168. data/app/views/editable_components/_block_text.html.erb +5 -0
  169. data/app/views/editable_components/_block_text_with_image.html.erb +12 -0
  170. data/app/views/editable_components/_blocks.html.erb +12 -0
  171. data/config/initializers/editable_components.rb +72 -0
  172. data/config/routes.rb +4 -0
  173. data/db/migrate/20170414173603_create_editable_components_blocks.rb +18 -0
  174. data/db/migrate/20170414173610_create_editable_components_items.rb +11 -0
  175. data/db/migrate/20170414173611_add_items_booleans.rb +5 -0
  176. data/db/migrate/20170414173612_add_items_datetimes.rb +5 -0
  177. data/db/migrate/20170414173613_add_items_files.rb +5 -0
  178. data/db/migrate/20170414173614_add_items_floats.rb +5 -0
  179. data/db/migrate/20170414173615_add_items_hashes.rb +5 -0
  180. data/db/migrate/20170414173616_add_items_integers.rb +5 -0
  181. data/db/migrate/20170414173617_add_items_strings.rb +5 -0
  182. data/db/migrate/20170414173618_add_items_texts.rb +5 -0
  183. data/lib/data/img1.jpg +0 -0
  184. data/lib/editable_components.rb +87 -0
  185. data/lib/editable_components/engine.rb +21 -0
  186. data/lib/editable_components/version.rb +3 -0
  187. data/lib/tasks/editable_components_tasks.rake +4 -0
  188. metadata +264 -0
@@ -0,0 +1 @@
1
+ .gu-mirror{position:fixed!important;margin:0!important;z-index:9999!important;opacity:.8;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80)}.gu-hide{display:none!important}.gu-unselectable{-webkit-user-select:none!important;-moz-user-select:none!important;-ms-user-select:none!important;user-select:none!important}.gu-transit{opacity:.2;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20)}
@@ -0,0 +1 @@
1
+ !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var n;n="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,n.dragula=e()}}(function(){return function e(n,t,r){function o(u,c){if(!t[u]){if(!n[u]){var a="function"==typeof require&&require;if(!c&&a)return a(u,!0);if(i)return i(u,!0);var f=new Error("Cannot find module '"+u+"'");throw f.code="MODULE_NOT_FOUND",f}var l=t[u]={exports:{}};n[u][0].call(l.exports,function(e){var t=n[u][1][e];return o(t?t:e)},l,l.exports,e,n,t,r)}return t[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,n,t){"use strict";function r(e){var n=u[e];return n?n.lastIndex=0:u[e]=n=new RegExp(c+e+a,"g"),n}function o(e,n){var t=e.className;t.length?r(n).test(t)||(e.className+=" "+n):e.className=n}function i(e,n){e.className=e.className.replace(r(n)," ").trim()}var u={},c="(?:^|\\s)",a="(?:\\s|$)";n.exports={add:o,rm:i}},{}],2:[function(e,n,t){(function(t){"use strict";function r(e,n){function t(e){return-1!==le.containers.indexOf(e)||fe.isContainer(e)}function r(e){var n=e?"remove":"add";o(S,n,"mousedown",O),o(S,n,"mouseup",L)}function c(e){var n=e?"remove":"add";o(S,n,"mousemove",N)}function m(e){var n=e?"remove":"add";w[n](S,"selectstart",C),w[n](S,"click",C)}function h(){r(!0),L({})}function C(e){ce&&e.preventDefault()}function O(e){ne=e.clientX,te=e.clientY;var n=1!==i(e)||e.metaKey||e.ctrlKey;if(!n){var t=e.target,r=T(t);r&&(ce=r,c(),"mousedown"===e.type&&(p(t)?t.focus():e.preventDefault()))}}function N(e){if(ce){if(0===i(e))return void L({});if(void 0===e.clientX||e.clientX!==ne||void 0===e.clientY||e.clientY!==te){if(fe.ignoreInputTextSelection){var n=y("clientX",e),t=y("clientY",e),r=x.elementFromPoint(n,t);if(p(r))return}var o=ce;c(!0),m(),D(),B(o);var a=u(W);Z=y("pageX",e)-a.left,ee=y("pageY",e)-a.top,E.add(ie||W,"gu-transit"),K(),U(e)}}}function T(e){if(!(le.dragging&&J||t(e))){for(var n=e;v(e)&&t(v(e))===!1;){if(fe.invalid(e,n))return;if(e=v(e),!e)return}var r=v(e);if(r&&!fe.invalid(e,n)){var o=fe.moves(e,r,n,g(e));if(o)return{item:e,source:r}}}}function X(e){return!!T(e)}function Y(e){var n=T(e);n&&B(n)}function B(e){$(e.item,e.source)&&(ie=e.item.cloneNode(!0),le.emit("cloned",ie,e.item,"copy")),Q=e.source,W=e.item,re=oe=g(e.item),le.dragging=!0,le.emit("drag",W,Q)}function P(){return!1}function D(){if(le.dragging){var e=ie||W;M(e,v(e))}}function I(){ce=!1,c(!0),m(!0)}function L(e){if(I(),le.dragging){var n=ie||W,t=y("clientX",e),r=y("clientY",e),o=a(J,t,r),i=q(o,t,r);i&&(ie&&fe.copySortSource||!ie||i!==Q)?M(n,i):fe.removeOnSpill?R():A()}}function M(e,n){var t=v(e);ie&&fe.copySortSource&&n===Q&&t.removeChild(W),k(n)?le.emit("cancel",e,Q,Q):le.emit("drop",e,n,Q,oe),j()}function R(){if(le.dragging){var e=ie||W,n=v(e);n&&n.removeChild(e),le.emit(ie?"cancel":"remove",e,n,Q),j()}}function A(e){if(le.dragging){var n=arguments.length>0?e:fe.revertOnSpill,t=ie||W,r=v(t),o=k(r);o===!1&&n&&(ie?r&&r.removeChild(ie):Q.insertBefore(t,re)),o||n?le.emit("cancel",t,Q,Q):le.emit("drop",t,r,Q,oe),j()}}function j(){var e=ie||W;I(),z(),e&&E.rm(e,"gu-transit"),ue&&clearTimeout(ue),le.dragging=!1,ae&&le.emit("out",e,ae,Q),le.emit("dragend",e),Q=W=ie=re=oe=ue=ae=null}function k(e,n){var t;return t=void 0!==n?n:J?oe:g(ie||W),e===Q&&t===re}function q(e,n,r){function o(){var o=t(i);if(o===!1)return!1;var u=H(i,e),c=V(i,u,n,r),a=k(i,c);return a?!0:fe.accepts(W,i,Q,c)}for(var i=e;i&&!o();)i=v(i);return i}function U(e){function n(e){le.emit(e,f,ae,Q)}function t(){s&&n("over")}function r(){ae&&n("out")}if(J){e.preventDefault();var o=y("clientX",e),i=y("clientY",e),u=o-Z,c=i-ee;J.style.left=u+"px",J.style.top=c+"px";var f=ie||W,l=a(J,o,i),d=q(l,o,i),s=null!==d&&d!==ae;(s||null===d)&&(r(),ae=d,t());var p=v(f);if(d===Q&&ie&&!fe.copySortSource)return void(p&&p.removeChild(f));var m,h=H(d,l);if(null!==h)m=V(d,h,o,i);else{if(fe.revertOnSpill!==!0||ie)return void(ie&&p&&p.removeChild(f));m=re,d=Q}(null===m&&s||m!==f&&m!==g(f))&&(oe=m,d.insertBefore(f,m),le.emit("shadow",f,d,Q))}}function _(e){E.rm(e,"gu-hide")}function F(e){le.dragging&&E.add(e,"gu-hide")}function K(){if(!J){var e=W.getBoundingClientRect();J=W.cloneNode(!0),J.style.width=d(e)+"px",J.style.height=s(e)+"px",E.rm(J,"gu-transit"),E.add(J,"gu-mirror"),fe.mirrorContainer.appendChild(J),o(S,"add","mousemove",U),E.add(fe.mirrorContainer,"gu-unselectable"),le.emit("cloned",J,W,"mirror")}}function z(){J&&(E.rm(fe.mirrorContainer,"gu-unselectable"),o(S,"remove","mousemove",U),v(J).removeChild(J),J=null)}function H(e,n){for(var t=n;t!==e&&v(t)!==e;)t=v(t);return t===S?null:t}function V(e,n,t,r){function o(){var n,o,i,u=e.children.length;for(n=0;u>n;n++){if(o=e.children[n],i=o.getBoundingClientRect(),c&&i.left+i.width/2>t)return o;if(!c&&i.top+i.height/2>r)return o}return null}function i(){var e=n.getBoundingClientRect();return u(c?t>e.left+d(e)/2:r>e.top+s(e)/2)}function u(e){return e?g(n):n}var c="horizontal"===fe.direction,a=n!==e?i():o();return a}function $(e,n){return"boolean"==typeof fe.copy?fe.copy:fe.copy(e,n)}var G=arguments.length;1===G&&Array.isArray(e)===!1&&(n=e,e=[]);var J,Q,W,Z,ee,ne,te,re,oe,ie,ue,ce,ae=null,fe=n||{};void 0===fe.moves&&(fe.moves=l),void 0===fe.accepts&&(fe.accepts=l),void 0===fe.invalid&&(fe.invalid=P),void 0===fe.containers&&(fe.containers=e||[]),void 0===fe.isContainer&&(fe.isContainer=f),void 0===fe.copy&&(fe.copy=!1),void 0===fe.copySortSource&&(fe.copySortSource=!1),void 0===fe.revertOnSpill&&(fe.revertOnSpill=!1),void 0===fe.removeOnSpill&&(fe.removeOnSpill=!1),void 0===fe.direction&&(fe.direction="vertical"),void 0===fe.ignoreInputTextSelection&&(fe.ignoreInputTextSelection=!0),void 0===fe.mirrorContainer&&(fe.mirrorContainer=x.body);var le=b({containers:fe.containers,start:Y,end:D,cancel:A,remove:R,destroy:h,canMove:X,dragging:!1});return fe.removeOnSpill===!0&&le.on("over",_).on("out",F),r(),le}function o(e,n,r,o){var i={mouseup:"touchend",mousedown:"touchstart",mousemove:"touchmove"},u={mouseup:"pointerup",mousedown:"pointerdown",mousemove:"pointermove"},c={mouseup:"MSPointerUp",mousedown:"MSPointerDown",mousemove:"MSPointerMove"};t.navigator.pointerEnabled?w[n](e,u[r],o):t.navigator.msPointerEnabled?w[n](e,c[r],o):(w[n](e,i[r],o),w[n](e,r,o))}function i(e){if(void 0!==e.touches)return e.touches.length;if(void 0!==e.which&&0!==e.which)return e.which;if(void 0!==e.buttons)return e.buttons;var n=e.button;return void 0!==n?1&n?1:2&n?3:4&n?2:0:void 0}function u(e){var n=e.getBoundingClientRect();return{left:n.left+c("scrollLeft","pageXOffset"),top:n.top+c("scrollTop","pageYOffset")}}function c(e,n){return"undefined"!=typeof t[n]?t[n]:S.clientHeight?S[e]:x.body[e]}function a(e,n,t){var r,o=e||{},i=o.className;return o.className+=" gu-hide",r=x.elementFromPoint(n,t),o.className=i,r}function f(){return!1}function l(){return!0}function d(e){return e.width||e.right-e.left}function s(e){return e.height||e.bottom-e.top}function v(e){return e.parentNode===x?null:e.parentNode}function p(e){return"INPUT"===e.tagName||"TEXTAREA"===e.tagName||"SELECT"===e.tagName||m(e)}function m(e){return e?"false"===e.contentEditable?!1:"true"===e.contentEditable?!0:m(v(e)):!1}function g(e){function n(){var n=e;do n=n.nextSibling;while(n&&1!==n.nodeType);return n}return e.nextElementSibling||n()}function h(e){return e.targetTouches&&e.targetTouches.length?e.targetTouches[0]:e.changedTouches&&e.changedTouches.length?e.changedTouches[0]:e}function y(e,n){var t=h(n),r={pageX:"clientX",pageY:"clientY"};return e in r&&!(e in t)&&r[e]in t&&(e=r[e]),t[e]}var b=e("contra/emitter"),w=e("crossvent"),E=e("./classes"),x=document,S=x.documentElement;n.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./classes":1,"contra/emitter":5,crossvent:6}],3:[function(e,n,t){n.exports=function(e,n){return Array.prototype.slice.call(e,n)}},{}],4:[function(e,n,t){"use strict";var r=e("ticky");n.exports=function(e,n,t){e&&r(function(){e.apply(t||null,n||[])})}},{ticky:9}],5:[function(e,n,t){"use strict";var r=e("atoa"),o=e("./debounce");n.exports=function(e,n){var t=n||{},i={};return void 0===e&&(e={}),e.on=function(n,t){return i[n]?i[n].push(t):i[n]=[t],e},e.once=function(n,t){return t._once=!0,e.on(n,t),e},e.off=function(n,t){var r=arguments.length;if(1===r)delete i[n];else if(0===r)i={};else{var o=i[n];if(!o)return e;o.splice(o.indexOf(t),1)}return e},e.emit=function(){var n=r(arguments);return e.emitterSnapshot(n.shift()).apply(this,n)},e.emitterSnapshot=function(n){var u=(i[n]||[]).slice(0);return function(){var i=r(arguments),c=this||e;if("error"===n&&t["throws"]!==!1&&!u.length)throw 1===i.length?i[0]:i;return u.forEach(function(r){t.async?o(r,i,c):r.apply(c,i),r._once&&e.off(n,r)}),e}},e}},{"./debounce":4,atoa:3}],6:[function(e,n,t){(function(t){"use strict";function r(e,n,t,r){return e.addEventListener(n,t,r)}function o(e,n,t){return e.attachEvent("on"+n,f(e,n,t))}function i(e,n,t,r){return e.removeEventListener(n,t,r)}function u(e,n,t){var r=l(e,n,t);return r?e.detachEvent("on"+n,r):void 0}function c(e,n,t){function r(){var e;return p.createEvent?(e=p.createEvent("Event"),e.initEvent(n,!0,!0)):p.createEventObject&&(e=p.createEventObject()),e}function o(){return new s(n,{detail:t})}var i=-1===v.indexOf(n)?o():r();e.dispatchEvent?e.dispatchEvent(i):e.fireEvent("on"+n,i)}function a(e,n,r){return function(n){var o=n||t.event;o.target=o.target||o.srcElement,o.preventDefault=o.preventDefault||function(){o.returnValue=!1},o.stopPropagation=o.stopPropagation||function(){o.cancelBubble=!0},o.which=o.which||o.keyCode,r.call(e,o)}}function f(e,n,t){var r=l(e,n,t)||a(e,n,t);return h.push({wrapper:r,element:e,type:n,fn:t}),r}function l(e,n,t){var r=d(e,n,t);if(r){var o=h[r].wrapper;return h.splice(r,1),o}}function d(e,n,t){var r,o;for(r=0;r<h.length;r++)if(o=h[r],o.element===e&&o.type===n&&o.fn===t)return r}var s=e("custom-event"),v=e("./eventmap"),p=t.document,m=r,g=i,h=[];t.addEventListener||(m=o,g=u),n.exports={add:m,remove:g,fabricate:c}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./eventmap":7,"custom-event":8}],7:[function(e,n,t){(function(e){"use strict";var t=[],r="",o=/^on/;for(r in e)o.test(r)&&t.push(r.slice(2));n.exports=t}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],8:[function(e,n,t){(function(e){function t(){try{var e=new r("cat",{detail:{foo:"bar"}});return"cat"===e.type&&"bar"===e.detail.foo}catch(n){}return!1}var r=e.CustomEvent;n.exports=t()?r:"function"==typeof document.createEvent?function(e,n){var t=document.createEvent("CustomEvent");return n?t.initCustomEvent(e,n.bubbles,n.cancelable,n.detail):t.initCustomEvent(e,!1,!1,void 0),t}:function(e,n){var t=document.createEventObject();return t.type=e,n?(t.bubbles=Boolean(n.bubbles),t.cancelable=Boolean(n.cancelable),t.detail=n.detail):(t.bubbles=!1,t.cancelable=!1,t.detail=void 0),t}}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],9:[function(e,n,t){var r,o="function"==typeof setImmediate;r=o?function(e){setImmediate(e)}:function(e){setTimeout(e,0)},n.exports=r},{}]},{},[2])(2)});
@@ -0,0 +1,225 @@
1
+ @font-face
2
+ font-family: 'icomoon'
3
+ font-style: normal
4
+ font-weight: normal
5
+ src: url('icomoon.eot?alv1ju')
6
+ src: url('icomoon.eot?alv1ju#iefix') format('embedded-opentype'), url('icomoon.ttf?alv1ju') format('truetype'), url('icomoon.woff?alv1ju') format('woff'), url('icomoon.svg?alv1ju#icomoon') format('svg')
7
+
8
+ .c-field--choice
9
+ margin-top: 5px
10
+
11
+ .noselect
12
+ -webkit-touch-callout: none
13
+ -webkit-user-select: none
14
+ -khtml-user-select: none
15
+ -moz-user-select: none
16
+ -ms-user-select: none
17
+ user-select: none
18
+
19
+ [data-ec-menu-publish], [data-ec-menu-save]
20
+ display: none
21
+
22
+ [data-ec-editing]
23
+ padding-bottom: 55px
24
+ .modal a.close-modal
25
+ top: 0
26
+ right: 0
27
+
28
+ [data-ec-editing='1']
29
+ [data-ec-block], [data-ec-sub-block]
30
+ box-shadow: inset 0 0 2px #468
31
+ min-height: 35px
32
+ position: relative
33
+ [data-ec-container=''] [data-ec-item], [data-ec-dlg] [data-ec-item]
34
+ background: repeating-linear-gradient( -45deg, #def, #def 10px, #f4f4f4 10px, #f4f4f4 20px )
35
+ box-shadow: inset 0 0 2px #789
36
+ cursor: pointer
37
+ [data-ec-item]
38
+ min-height: 15px
39
+ [data-ec-menu-publish], [data-ec-menu-save]
40
+ display: inline
41
+
42
+ [data-ec-new-block], [data-ec-new-sub-block], [data-ec-newblk-dlg], [data-ec-newsubcmp]
43
+ background: #def
44
+ border: 1px dashed #789
45
+ font-style: italic
46
+ margin-top: 5px
47
+ padding: 8px
48
+ position: relative
49
+ text-align: center
50
+ [data-ec-icon]
51
+ margin: 0
52
+
53
+ [data-ec-status]
54
+ color: #eee
55
+ padding: 6px 0
56
+ text-align: center
57
+
58
+ [data-ec-form]
59
+ display: inline-block
60
+
61
+ [data-ec-menu-dropup]
62
+ bottom: 100%
63
+ color: #444
64
+ display: none
65
+ position: absolute
66
+ width: 200px
67
+
68
+ [data-ec-toolbar]
69
+ background: rgba(0, 0, 0, .75)
70
+ z-index: 1000
71
+ a
72
+ color: #fff
73
+ text-decoration: none
74
+ a:hover
75
+ background-color: transparent
76
+ .c-nav__item--right
77
+ padding-left: 5px
78
+ padding-right: 5px
79
+ &.last-item
80
+ margin-right: 10px
81
+ .c-button
82
+ margin-bottom: 4px
83
+ .c-card__item
84
+ line-height: initial
85
+ .item-menu-add
86
+ display: none
87
+
88
+ [data-ec-btn-add]
89
+ float: right
90
+ font-size: 80%
91
+
92
+ [data-ec-block-buttons], [data-ec-new-block] > button, [data-ec-new-sub-block] > button
93
+ padding: 2px 2px 1px 3px
94
+ position: absolute
95
+ right: 5px
96
+ top: 5px
97
+
98
+ [data-ec-block-buttons] button
99
+ padding: 4px 4px 3px 5px
100
+
101
+ [data-ec-new-block] > button
102
+ padding: 2px 2px 1px 3px
103
+
104
+ [data-ec-btn-destroy], [data-ec-btn-cancel], [data-ec-btn-settings], .ec-btn-sort
105
+ border-radius: 20px
106
+ margin-top: 4px
107
+ padding: 4px 4px 5px 5px
108
+ position: absolute
109
+ text-shadow: 1px 1px #000
110
+ z-index: 999
111
+
112
+ [data-ec-btn-destroy], [data-ec-btn-cancel]
113
+ background: #a00
114
+ color: #fff
115
+ cursor: no-drop
116
+ right: 28px
117
+
118
+ [data-ec-btn-destroy]
119
+ display: none
120
+
121
+ [data-ec-destroy='1']
122
+ opacity: 0.3
123
+
124
+ [data-ec-btn-settings]
125
+ background: #e80
126
+ color: #fff
127
+ cursor: pointer
128
+ display: none
129
+ right: 52px
130
+
131
+ .ec-btn-sort
132
+ background: #080
133
+ color: #fff
134
+ cursor: move
135
+ cursor: -webkit-grabbing
136
+ display: none
137
+ right: 4px
138
+
139
+ // --- dialogs -------------------------------------------------------------- //
140
+ [data-ec-dlg]
141
+ display: none
142
+
143
+ [data-ec-dlg='preview']
144
+ .c-card__body
145
+ height: 100%
146
+ margin-top: 20px
147
+ padding: 0
148
+ .o-modal
149
+ height: 90%
150
+ padding: 0
151
+ &[data-ec-target='mobile']
152
+ max-width: 480px
153
+ iframe
154
+ width: 480px
155
+ &[data-ec-target='tablet']
156
+ max-width: 768px
157
+ iframe
158
+ width: 768px
159
+ iframe
160
+ border: 0 none
161
+ height: 100%
162
+
163
+ [data-ec-dlg='options']
164
+ .o-modal
165
+ padding: 14px 12px
166
+ [data-ec-type='ItemImage']
167
+ vertical-align: middle
168
+ max-width: 200px
169
+ max-height: 150px
170
+ [data-ec-sub-block]
171
+ margin-bottom: 5px
172
+ position: relative
173
+ .c-card__footer
174
+ text-align: right
175
+
176
+ [data-ec-dlg-buttons]
177
+ margin-top: 3px
178
+ position: absolute
179
+ right: 10px
180
+ font-size: 80%
181
+
182
+ // --- icons ---------------------------------------------------------------- //
183
+ [data-ec-icon]
184
+ font-family: 'icomoon' !important
185
+ speak: none
186
+ font-style: normal
187
+ font-weight: normal
188
+ font-variant: normal
189
+ text-transform: none
190
+ line-height: 1
191
+ -webkit-font-smoothing: antialiased
192
+ -moz-osx-font-smoothing: grayscale
193
+ [data-ec-icon='icon-pencil']:before
194
+ content: '\e905'
195
+ [data-ec-icon='icon-image']:before
196
+ content: '\e90d'
197
+ [data-ec-icon='icon-file-text2']:before
198
+ content: '\e926'
199
+ [data-ec-icon='icon-mobile2']:before
200
+ content: '\e959'
201
+ [data-ec-icon='icon-upload']:before
202
+ content: '\e961'
203
+ [data-ec-icon='icon-floppy-disk']:before
204
+ content: '\e962'
205
+ [data-ec-icon='icon-user']:before
206
+ content: '\e971'
207
+ [data-ec-icon='icon-search']:before
208
+ content: '\e986'
209
+ [data-ec-icon='icon-cog']:before
210
+ content: '\e994'
211
+ [data-ec-icon='icon-bin']:before
212
+ content: '\e9ac'
213
+ [data-ec-icon='icon-eye']:before
214
+ content: '\e9ce'
215
+ [data-ec-icon='icon-eye-blocked']:before
216
+ content: '\e9d1'
217
+ [data-ec-icon='icon-plus']:before
218
+ content: '\ea0a'
219
+ [data-ec-icon='icon-move-down']:before
220
+ content: '\ea47'
221
+
222
+ // -------------------------------------------------------------------------- //
223
+
224
+ [v-cloak]
225
+ display: none
@@ -0,0 +1,520 @@
1
+ # MediumEditor Object API (v5.0.0)
2
+
3
+ <!-- START doctoc generated TOC please keep comment here to allow auto update -->
4
+ <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
5
+
6
+
7
+ - [Initialization Functions](#initialization-functions)
8
+ - [`MediumEditor(elements, options)`](#mediumeditorelements-options)
9
+ - [`destroy()`](#destroy)
10
+ - [`setup()`](#setup)
11
+ - [`addElements()`](#addelementselements)
12
+ - [`removeElements()`](#removeelementselements)
13
+ - [Event Functions](#event-functions)
14
+ - [`on(targets, event, listener, useCapture)`](#ontargets-event-listener-usecapture)
15
+ - [`off(targets, event, listener, useCapture)`](#offtargets-event-listener-usecapture)
16
+ - [`subscribe(name, listener)`](#subscribename-listener)
17
+ - [`unsubscribe(name, listener)`](#unsubscribename-listener)
18
+ - [`trigger(name, data, editable)`](#triggername-data-editable)
19
+ - [Selection Functions](#selection-functions)
20
+ - [`checkSelection()`](#checkselection)
21
+ - [`exportSelection()`](#exportselection)
22
+ - [`importSelection(selectionState, favorLaterSelectionAnchor)`](#importselectionselectionstate-favorlaterselectionanchor)
23
+ - [`getFocusedElement()`](#getfocusedelement)
24
+ - [`getSelectedParentElement(range)`](#getselectedparentelementrange)
25
+ - [`restoreSelection()`](#restoreselection)
26
+ - [`saveSelection()`](#saveselection)
27
+ - [`selectAllContents()`](#selectallcontents)
28
+ - [`selectElement(element)`](#selectelementelement)
29
+ - [`stopSelectionUpdates()`](#stopselectionupdates)
30
+ - [`startSelectionUpdates()`](#startselectionupdates)
31
+ - [Editor Action Functions](#editor-action-functions)
32
+ - [`cleanPaste(text)`](#cleanpastetext)
33
+ - [`createLink(opts)`](#createlinkopts)
34
+ - [`execAction(action, opts)`](#execactionaction-opts)
35
+ - [`pasteHTML(html, options)`](#pastehtmlhtml-options)
36
+ - [`queryCommandState(action)`](#querycommandstateaction)
37
+ - [Helper Functions](#helper-functions)
38
+ - [`checkContentChanged(editable)`](#checkContentChangededitable)
39
+ - [`delay(fn)`](#delayfn)
40
+ - [`getContent(index)`](#getcontentindex)
41
+ - [`getExtensionByName(name)`](#getextensionbynamename)
42
+ - [`resetContent(element)`](#resetcontentelement)
43
+ - [`serialize()`](#serialize)
44
+ - [`setContent(html, index)`](#setcontenthtml-index)
45
+ - [Static Functions/Properties](#static-functionsproperties)
46
+ - [`getEditorFromElement(element)`](#geteditorfromelementelement)
47
+ - [`version`](#version)
48
+
49
+ <!-- END doctoc generated TOC please keep comment here to allow auto update -->
50
+
51
+ ## Initialization Functions
52
+
53
+ ### `MediumEditor(elements, options)`
54
+
55
+ Creating an instance of MediumEditor will:
56
+ * Convert all passed in elements into `contenteditable` elements.
57
+ * For any `<textarea>` elements:
58
+ * Hide the `<textarea>`
59
+ * Create a new `<div contenteditable=true>` element and add it to the elements array.
60
+ * Ensure the 2 elements remain sync'd.
61
+ * Initialize any custom extensions or buttons passed in.
62
+ * Create any additional elements needed.
63
+ * Setup all event handling needed to monitor the editable elements.
64
+
65
+ **Arguments**
66
+
67
+ _**elements** (`String` | `HTMLElement` | `Array` | `NodeList` | `HTMLCollection`)_:
68
+
69
+ 1. `String`: If passed as a string, this is used as a selector in a call to `document.querySelectorAll()` to find elements on the page. All results are stored in the internal list of **elements**.
70
+
71
+ 2. `HTMLElement`: If passed as a single element, this will be the only element in the internal list of **elements**.
72
+
73
+ 3. `Array`: If passed as an `Array` of `HTMLElement`s, this will be used as the internal list of **elements**.
74
+
75
+ _**options** (`Object`)_:
76
+
77
+ Set of [custom options](OPTIONS.md) used to initialize `MediumEditor`.
78
+
79
+ ***
80
+ ### `destroy()`
81
+
82
+ Tear down the editor if already setup by doing the following:
83
+ * Calling the `destroy()` method on each extension within the editor. This should allow all extension to be torn down and cleaned up, including the toolbar and its elements.
84
+ * Detaching all event listeners from the DOM
85
+ * Detaching all references to custom event listeners
86
+ * Remove any custom attributes from the editor **elements**
87
+ * Unhide any `<textarea>` elements and remove any created `<div>` elements created for `<textarea>` elements.
88
+
89
+ ***
90
+ ### `setup()`
91
+
92
+ Initialize this instance of the editor if it has been destroyed. This will reuse the `elements` selector and `options` object passed in when the editor was instantiated.
93
+
94
+ ***
95
+ ### `addElements(elements)`
96
+
97
+ Dynamically add one or more elements to an already initialized instance of MediumEditor.
98
+
99
+ Passing an elements or array of elements to `addElements(elements)` will:
100
+ * Add the given element or array of elements to the editor **elements**
101
+ * Ensure the element(s) are initialized with the proper attributes and event handlers as if the element had been passed during instantiation of the editor
102
+ * For any `<textarea>` elements:
103
+ * Hide the `<textarea>`
104
+ * Create a new `<div contenteditable=true>` element and add it to the editor **elements**
105
+ * Ensure the 2 elements remain sync'd.
106
+ * Be intelligent enough to run the necessary code only once per element, no matter how often you will call it
107
+
108
+ So, every element you pass to `addElements` will turn into a fully supported contenteditable too - even earlier calls to `editor.subscribe(..)`
109
+ for custom events will work on the newly added element(s).
110
+
111
+ **Arguments**
112
+
113
+ _**elements** (`String` | `HTMLElement` | `Array` | `NodeList` | `HTMLCollection`)_:
114
+
115
+ 1. `String`: If passed as a string, this is used as a selector in a call to `document.querySelectorAll()` to find elements on the page.
116
+
117
+ 2. `HTMLElement`: If passed as a single element, this will be the only element added to the editor **elements**.
118
+
119
+ 3. `Array` | `NodeList` | `HTMLCollection`: If passed as an `Array`-like collection of `HTMLElement`s, all of these elements will be added to the editor **elements**.
120
+
121
+ ***
122
+ ### `removeElements(elements)`
123
+
124
+ Remove one or more elements from an already initialized instance of MediumEditor.
125
+
126
+ Passing an elements or array of elements to `removeElements(elements)` will:
127
+ * Remove the given element or array of elements from the internal `this.elements` array.
128
+ * Remove any added event handlers or attributes (with the exception of `contenteditable`).
129
+ * Unhide any `<textarea>` elements and remove any created `<div>` elements created for `<textarea>` elements.
130
+
131
+ Each element itself will remain a contenteditable - it will just remove all event handlers and all references to it so you can safely remove it from DOM.
132
+
133
+ **Arguments**
134
+
135
+ _**elements** (`String` | `HTMLElement` | `Array` | `NodeList` | `HTMLCollection`)_:
136
+
137
+ 1. `String`: If passed as a string, this is used as a selector in a call to `document.querySelectorAll()` to find elements on the page.
138
+
139
+ 2. `HTMLElement`: If passed as a single element, this will be the only element removed from the editor **elements**.
140
+
141
+ 3. `Array` | `NodeList` | `HTMLCollection`: If passed as an `Array`-like collection of `HTMLElement`s, all of these elements will be removed from the editor **elements**.
142
+
143
+ ***
144
+ ## Event Functions
145
+
146
+ ### `on(targets, event, listener, useCapture)`
147
+
148
+ Attaches an event listener to a specific element or elements via the browser's built-in `addEventListener(type, listener, useCapture)` API. However, this helper method also ensures that when MediumEditor is destroyed, this event listener will be automatically be detached from the DOM.
149
+
150
+ **Arguments**
151
+
152
+ 1. _**targets** (`HTMLElement` / `NodeList`)_:
153
+
154
+ * Element or elements to attach listener to via `addEventListener(type, listener, useCapture)`
155
+
156
+ 2. _**event** (`String`)_:
157
+
158
+ * type argument for `addEventListener(type, listener, useCapture)`
159
+
160
+ 3. _**listener** (`function`)_:
161
+
162
+ * listener argument for `addEventListener(type, listener, useCapture)`
163
+
164
+ 4. _**useCapture** (`boolean`)_:
165
+
166
+ * useCapture argument for `addEventListener(type, listener, useCapture)`
167
+
168
+ ***
169
+ ### `off(targets, event, listener, useCapture)`
170
+
171
+ Detach an event listener from a specific element or elements via the browser's built-in `removeEventListener(type, listener, useCapture)` API.
172
+
173
+ **Arguments**
174
+
175
+ 1. _**targets** (`HTMLElement` / `NodeList`)_:
176
+
177
+ * Element or elements to detach listener from via `removeEventListener(type, listener, useCapture)`
178
+
179
+ 2. _**event** (`String`)_:
180
+
181
+ * type argument for `removeEventListener(type, listener, useCapture)`
182
+
183
+ 3. _**listener** (`function`)_:
184
+
185
+ * listener argument for `removeEventListener(type, listener, useCapture)`
186
+
187
+ 4. _**useCapture** (`boolean`)_:
188
+
189
+ * useCapture argument for `removeEventListener(type, listener, useCapture)`
190
+
191
+ ***
192
+ ### `subscribe(name, listener)`
193
+
194
+ Attaches a listener for the specified custom event name.
195
+
196
+ **Arguments**
197
+
198
+ 1. _**name** (`String`)_:
199
+
200
+ * Name of the event to listen to. See the list of built-in [Custom Events](CUSTOM-EVENTS.md).
201
+
202
+ 2. _**listener(data, editable)** (`function`)_:
203
+
204
+ * Listener method that will be called whenever the custom event is triggered.
205
+
206
+ **Arguments to listener**
207
+
208
+ 1. _**data** (`Event` | `object`)_
209
+ * For most custom events, this will be the browser's native `Event` object for the event that triggered the custom event to fire.
210
+ * For some custom events, this will be an object containing information describing the event (depending on which custom event it is)
211
+ 2. _**editable** (`HTMLElement`)_
212
+ * A reference to the contenteditable container element that this custom event corresponds to. This is especially useful for instances where one instance of MediumEditor contains multiple elements, or there are multiple instances of MediumEditor on the page.
213
+ * For example, when `blur` fires, this argument will be the `<div contenteditable=true></div>` element that is about to receive focus.
214
+
215
+ ***
216
+ ### `unsubscribe(name, listener)`
217
+
218
+ Detaches a custom event listener for the specified custom event name.
219
+
220
+ **Arguments**
221
+
222
+ 1. _**name** (`String`)_:
223
+
224
+ * Name of the event to detach the listener for.
225
+
226
+ 2. _**listener** (`function`)_:
227
+
228
+ * A reference to the listener to detach. This must be a match by-reference and not a copy.
229
+
230
+ **NOTE**
231
+
232
+ * Calling [destroy()](#destroy) on the MediumEditor object will automatically remove all custom event listeners.
233
+
234
+ ***
235
+ ### `trigger(name, data, editable)`
236
+
237
+ Manually triggers a custom event.
238
+
239
+ **Arguments**
240
+
241
+ 1. _**name** (`String`)_:
242
+
243
+ * Name of the custom event to trigger.
244
+
245
+ 2. _**data** (`Event` | `object`)_:
246
+
247
+ * Native `Event` object or custom data object to pass to all the listeners to this custom event.
248
+
249
+ 3. _**editable** (`HTMLElement`)_:
250
+
251
+ * The `<div contenteditable=true></div>` element to pass to all of the listeners to this custom event.
252
+
253
+ ***
254
+ ## Selection Functions
255
+
256
+ ### `checkSelection()`
257
+
258
+ If the toolbar is enabled, manually forces the toolbar to update based on the user's current selection. This includes hiding/showing the toolbar, positioning the toolbar, and updating the enabled/disable state of the toolbar buttons.
259
+
260
+ ***
261
+ ### `exportSelection()`
262
+
263
+ Returns a data representation of the selected text, which can be applied via `importSelection(selectionState)`. This data will include the beginning and end of the selection, as well as which of the editor **elements** the selection was within.
264
+
265
+ ***
266
+ ### `importSelection(selectionState, favorLaterSelectionAnchor)`
267
+
268
+ Restores the selection using a data representation of previously selected text (ie value returned by `exportSelection()`).
269
+
270
+ **Arguments**
271
+
272
+ 1. _**selectionState** (`Object`)_:
273
+
274
+ * Data representing the state of the selection to restore.
275
+
276
+ 2. _**favorLaterSelectionAnchor** (`boolean`)_:
277
+
278
+ * If `true`, import the cursor immediately subsequent to an anchor tag if it would otherwise be placed right at the trailing edge inside the anchor. THis cursor positioning, even though visually equivalent to the user, can affect behavior in Internet Explorer.
279
+
280
+ ***
281
+ ### `getFocusedElement()`
282
+
283
+ Returns a reference to the editor **element** that currently has focus (if the editor has focus).
284
+
285
+ ***
286
+ ### `getSelectedParentElement(range)`
287
+
288
+ Returns a reference to the editor **element** that the user's selection is currently within.
289
+
290
+ **Arguments**
291
+
292
+ 1. _**range** (`Range`)_: _**OPTIONAL**_
293
+ * The `Range` to find the selection parent element within
294
+ * If no element is provided, the editor will use the current range within the selection of the editor's `contentWindow`
295
+
296
+ ***
297
+ ### `restoreSelection()`
298
+
299
+ Restores the selection to what was selected the last time `saveSelection()` was called.
300
+
301
+ ***
302
+ ### `saveSelection()`
303
+
304
+ Internally stores the user's current selection. This can be restored by calling `restoreSelection()`.
305
+
306
+ ***
307
+ ### `selectAllContents()`
308
+
309
+ Expands the selection to contain all text within the focused editor **element**.
310
+
311
+ ***
312
+ ### `selectElement(element)`
313
+
314
+ Change the user's selection to select the contents of the provided element and update the toolbar to reflect this change.
315
+
316
+ **Arguments**
317
+
318
+ 1. _**element** (`HTMLElement`)_:
319
+
320
+ * DOM Element -- which is a descendant of one of the editor's **elements** -- to select.
321
+
322
+ ***
323
+ ### `stopSelectionUpdates()`
324
+
325
+ Stop the toolbar from updating to reflect changes in the user's selection.
326
+
327
+ ***
328
+ ### `startSelectionUpdates()`
329
+
330
+ Enable the toolbar to start updating based on the user's selection, after a call to `stopSelectionUpdates()`
331
+
332
+ ***
333
+ ## Editor Action Functions
334
+
335
+ ### `cleanPaste(text)`
336
+ _convert text to plaintext and replace current selection with result_
337
+
338
+ **Arguments**
339
+
340
+ 1. _**text** (`String`)_:
341
+
342
+ * Content to be pasted at the location of the current selection/cursor
343
+
344
+ ***
345
+ ### `createLink(opts)`
346
+ _creates a link via the native `document.execCommand('createLink')` command_
347
+
348
+ **Arguments**
349
+
350
+ 1. _**opts** (`Object`)_:
351
+
352
+ * Object containing additional properties needed for creating a link
353
+
354
+ **Properties of 'opts'**
355
+
356
+ 1. _**value** (`String`)_ _**REQUIRED**_
357
+ * The url to set as the `href` of the created link. A non-empty value must be provided for the link to be created.
358
+ 2. _**target** (`String`)_
359
+ * Attribute to set as the `target` attribute of the created link. Passing 'self' or not passing this option at all are equivalent in that they will just ensure that `target="_blank"` will NOT be present on the created link.
360
+ * **NOTE** If the `targetBlank` option on the editor is set to true, the `target` property of opts will be ignored and `target="_blank"` will be added to all created links.
361
+ 3. _**buttonClass** (`String`)_
362
+ * Class (or classes) to append to the `class` attribute of the created link.
363
+
364
+ ##### Example
365
+
366
+ ```js
367
+ editor.createLink({ value: 'https://github.com/yabwe/medium-editor', target: '_blank', buttonClass: 'medium-link' });
368
+ ```
369
+
370
+ ***
371
+ ### `execAction(action, opts)`
372
+ _executes an built-in action via document.execCommand_
373
+
374
+ **Arguments**
375
+
376
+ 1. _**action** (`String`)_:
377
+
378
+ * Action to be passed as the 'command' argument to `document.execCommand(command, showDefaultUI, value)`
379
+
380
+ 2. _**opts** (`Object`)_ _**OPTIONAL**_:
381
+
382
+ * Object containing additional properties for specific commands
383
+
384
+ **Properties of 'opts'**
385
+
386
+ 1. _**value** (`String`)_
387
+ * The value to pass as the 'value' argument to `document.execCommand(command, showDefaultUI, value)`
388
+ 2. For 'createLink', the `opts` are passed directly to [`.createLink(opts)`]((#createlinkopts)) so see that method for additional options for that command
389
+
390
+ ***
391
+ ### `pasteHTML(html, options)`
392
+ _replace the current selection with html_
393
+
394
+ **Arguments**
395
+
396
+ 1. _**html** (`String`)_:
397
+
398
+ * Content to be pasted at the location of the current selection/cursor
399
+
400
+ 2. _**options** (`Object`)_ _**OPTIONAL**_:
401
+
402
+ * Optional overrides for `cleanTags`, `unwrapTags`, and/or `cleanAttrs` for removing/unwrapping specific element types (`cleanTags`/`unwrapTags`), or removing specific attributes (`cleanAttrs`) from the inserted HTML. See [cleanTags](OPTIONS.md#cleantags), [unwrapTags](OPTIONS.md#unwraptags), and [cleanAttrs](OPTIONS.md#cleanattrs) in OPTIONS.md for more information.
403
+
404
+ ##### Example
405
+
406
+ ```js
407
+ editor.pasteHTML('<p class="classy"><strong>Some Custom HTML</strong></p>', { cleanAttrs: ['class'], cleanTags: ['strong'], unwrapTags: ['em']});
408
+ ```
409
+
410
+ ***
411
+ ### `queryCommandState(action)`
412
+ _wrapper around the browser's built in `document.queryCommandState(command)` for checking whether a specific action has already been applied to the selection._
413
+
414
+ **Arguments**
415
+
416
+ 1. _**action** (`String`)_:
417
+
418
+ * Action to be passed as the 'command' argument to `document.queryCommandState(command)`
419
+
420
+ ***
421
+ ## Helper Functions
422
+
423
+ ### `checkContentChanged(editable)`
424
+
425
+ Trigger the editor to check for updates to the html, and trigger the `editableInput` event if needed.
426
+
427
+ **Arguments**
428
+
429
+ 1. _**editable** (`HTMLElement`)_: _**OPTIONAL**_
430
+ * The `<div contenteditable=true></div>` element that contains the html that may have changed.
431
+ * If no element is provided, the editor will check the currently 'active' editor element (the element with focus).
432
+
433
+ ### `delay(fn)`
434
+
435
+ Delay any function from being executed by the amount of time passed as the **delay** option.
436
+
437
+ **Arguments**
438
+
439
+ 1. _**fn** (`function`)_:
440
+
441
+ * Function to delay execution for.
442
+
443
+ ***
444
+ ### `getContent(index)`
445
+
446
+ Returns the trimmed html content for the first editor **element**, or the **element** at `index`.
447
+
448
+ **Arguments**
449
+
450
+ 1. _**index** (`integer`)_: _**OPTIONAL**_
451
+ * Index of the editor **element** to retrieve the content from. Defaults to 0 when not provided (returns content of the first editor **element**).
452
+
453
+ ***
454
+ ### `getExtensionByName(name)`
455
+
456
+ Get a reference to an extension with the specified name.
457
+
458
+ **Arguments**
459
+
460
+ 1. _**name** (`String`)_:
461
+
462
+ * The name of the extension to retrieve (ie `toolbar`).
463
+
464
+ ***
465
+ ### `resetContent(element)`
466
+
467
+ Reset the content of all editor **elements** to their value at the time they were added to the editor. If a specific editor **element** is provided, only the content of that element will be reset.
468
+
469
+ **Arguments**
470
+
471
+ 1. _**element** (`DOMElement`)_: _**OPTIONAL**_
472
+
473
+ * Specific editor **element** to reset the content of.
474
+
475
+ ***
476
+ ### `serialize()`
477
+
478
+ Returns a JSON object including the content of each of the **elements** inside the editor.
479
+
480
+ ***
481
+ ### `setContent(html, index)`
482
+
483
+ Sets the html content for the first editor **element**, or the **element** at `index`. Ensures the the `editableInput` event is triggered.
484
+
485
+ **Arguments**
486
+
487
+ 1. _**html** (`string`)_:
488
+ * The content to set the element to
489
+
490
+ 2. _**index** (`integer`)_: _**OPTIONAL**_
491
+ * Index of the editor **element** to set the content of. Defaults to 0 when not provided (sets content of the first editor **element**).
492
+
493
+ ***
494
+ ## Static Functions/Properties
495
+
496
+ ### `getEditorFromElement(element)`
497
+
498
+ Given an editor **element**, retrieves the instance of MediumEditor which created/is monitoring the **element**
499
+
500
+ **Arguments**
501
+
502
+ 1. _**element** (`DOMElement`)_:
503
+ * An editor **element** which is part of a MediumEditor instance
504
+
505
+ ### `version`
506
+
507
+ Object containing data about the version of the current MediumEditor library
508
+
509
+ **Properties of 'version'**
510
+
511
+ 1. _**major** (`Number`)_
512
+ * The major version number (ie the `3` in `"3.2.1"`)
513
+ 2. _**minor** (`Number`)_
514
+ * The minor version number (ie the `2` in `"3.2.1"`)
515
+ 3. _**revision** (`Number`)_
516
+ * The revision (aka "patch") version number (ie the `1` in `"3.2.1"`)
517
+ 4. _**preRelease** (`String`)_
518
+ * The pre-release version tag (ie the `"rc.1"` in `"5.0.0-rc.1"`)
519
+ 5. _**toString** (`Function`)_
520
+ * Returns the full version number as a string (ie `"5.0.0-rc.1"`)