all repos — NoPaste @ 3e3c433f026c49e04d0efa0f0f39fc688ed32bb1

Resurrected - The PussTheCat.org fork of NoPaste

scripts/clipboard.js (view raw)

  1/*!
  2 * clipboard.js v2.0.8
  3 * https://clipboardjs.com/
  4 *
  5 * Licensed MIT © Zeno Rocha
  6 */
  7(function webpackUniversalModuleDefinition(root, factory) {
  8	if(typeof exports === 'object' && typeof module === 'object')
  9		module.exports = factory();
 10	else if(typeof define === 'function' && define.amd)
 11		define([], factory);
 12	else if(typeof exports === 'object')
 13		exports["ClipboardJS"] = factory();
 14	else
 15		root["ClipboardJS"] = factory();
 16})(this, function() {
 17return /******/ (function() { // webpackBootstrap
 18/******/ 	var __webpack_modules__ = ({
 19
 20/***/ 134:
 21/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
 22
 23"use strict";
 24
 25// EXPORTS
 26__webpack_require__.d(__webpack_exports__, {
 27  "default": function() { return /* binding */ clipboard; }
 28});
 29
 30// EXTERNAL MODULE: ./node_modules/tiny-emitter/index.js
 31var tiny_emitter = __webpack_require__(279);
 32var tiny_emitter_default = /*#__PURE__*/__webpack_require__.n(tiny_emitter);
 33// EXTERNAL MODULE: ./node_modules/good-listener/src/listen.js
 34var listen = __webpack_require__(370);
 35var listen_default = /*#__PURE__*/__webpack_require__.n(listen);
 36// EXTERNAL MODULE: ./node_modules/select/src/select.js
 37var src_select = __webpack_require__(817);
 38var select_default = /*#__PURE__*/__webpack_require__.n(src_select);
 39;// CONCATENATED MODULE: ./src/clipboard-action.js
 40function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
 41
 42function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
 43
 44function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
 45
 46function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
 47
 48
 49/**
 50 * Inner class which performs selection from either `text` or `target`
 51 * properties and then executes copy or cut operations.
 52 */
 53
 54var ClipboardAction = /*#__PURE__*/function () {
 55  /**
 56   * @param {Object} options
 57   */
 58  function ClipboardAction(options) {
 59    _classCallCheck(this, ClipboardAction);
 60
 61    this.resolveOptions(options);
 62    this.initSelection();
 63  }
 64  /**
 65   * Defines base properties passed from constructor.
 66   * @param {Object} options
 67   */
 68
 69
 70  _createClass(ClipboardAction, [{
 71    key: "resolveOptions",
 72    value: function resolveOptions() {
 73      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
 74      this.action = options.action;
 75      this.container = options.container;
 76      this.emitter = options.emitter;
 77      this.target = options.target;
 78      this.text = options.text;
 79      this.trigger = options.trigger;
 80      this.selectedText = '';
 81    }
 82    /**
 83     * Decides which selection strategy is going to be applied based
 84     * on the existence of `text` and `target` properties.
 85     */
 86
 87  }, {
 88    key: "initSelection",
 89    value: function initSelection() {
 90      if (this.text) {
 91        this.selectFake();
 92      } else if (this.target) {
 93        this.selectTarget();
 94      }
 95    }
 96    /**
 97     * Creates a fake textarea element, sets its value from `text` property,
 98     */
 99
100  }, {
101    key: "createFakeElement",
102    value: function createFakeElement() {
103      var isRTL = document.documentElement.getAttribute('dir') === 'rtl';
104      this.fakeElem = document.createElement('textarea'); // Prevent zooming on iOS
105
106      this.fakeElem.style.fontSize = '12pt'; // Reset box model
107
108      this.fakeElem.style.border = '0';
109      this.fakeElem.style.padding = '0';
110      this.fakeElem.style.margin = '0'; // Move element out of screen horizontally
111
112      this.fakeElem.style.position = 'absolute';
113      this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px'; // Move element to the same position vertically
114
115      var yPosition = window.pageYOffset || document.documentElement.scrollTop;
116      this.fakeElem.style.top = "".concat(yPosition, "px");
117      this.fakeElem.setAttribute('readonly', '');
118      this.fakeElem.value = this.text;
119      return this.fakeElem;
120    }
121    /**
122     * Get's the value of fakeElem,
123     * and makes a selection on it.
124     */
125
126  }, {
127    key: "selectFake",
128    value: function selectFake() {
129      var _this = this;
130
131      var fakeElem = this.createFakeElement();
132
133      this.fakeHandlerCallback = function () {
134        return _this.removeFake();
135      };
136
137      this.fakeHandler = this.container.addEventListener('click', this.fakeHandlerCallback) || true;
138      this.container.appendChild(fakeElem);
139      this.selectedText = select_default()(fakeElem);
140      this.copyText();
141      this.removeFake();
142    }
143    /**
144     * Only removes the fake element after another click event, that way
145     * a user can hit `Ctrl+C` to copy because selection still exists.
146     */
147
148  }, {
149    key: "removeFake",
150    value: function removeFake() {
151      if (this.fakeHandler) {
152        this.container.removeEventListener('click', this.fakeHandlerCallback);
153        this.fakeHandler = null;
154        this.fakeHandlerCallback = null;
155      }
156
157      if (this.fakeElem) {
158        this.container.removeChild(this.fakeElem);
159        this.fakeElem = null;
160      }
161    }
162    /**
163     * Selects the content from element passed on `target` property.
164     */
165
166  }, {
167    key: "selectTarget",
168    value: function selectTarget() {
169      this.selectedText = select_default()(this.target);
170      this.copyText();
171    }
172    /**
173     * Executes the copy operation based on the current selection.
174     */
175
176  }, {
177    key: "copyText",
178    value: function copyText() {
179      var succeeded;
180
181      try {
182        succeeded = document.execCommand(this.action);
183      } catch (err) {
184        succeeded = false;
185      }
186
187      this.handleResult(succeeded);
188    }
189    /**
190     * Fires an event based on the copy operation result.
191     * @param {Boolean} succeeded
192     */
193
194  }, {
195    key: "handleResult",
196    value: function handleResult(succeeded) {
197      this.emitter.emit(succeeded ? 'success' : 'error', {
198        action: this.action,
199        text: this.selectedText,
200        trigger: this.trigger,
201        clearSelection: this.clearSelection.bind(this)
202      });
203    }
204    /**
205     * Moves focus away from `target` and back to the trigger, removes current selection.
206     */
207
208  }, {
209    key: "clearSelection",
210    value: function clearSelection() {
211      if (this.trigger) {
212        this.trigger.focus();
213      }
214
215      document.activeElement.blur();
216      window.getSelection().removeAllRanges();
217    }
218    /**
219     * Sets the `action` to be performed which can be either 'copy' or 'cut'.
220     * @param {String} action
221     */
222
223  }, {
224    key: "destroy",
225
226    /**
227     * Destroy lifecycle.
228     */
229    value: function destroy() {
230      this.removeFake();
231    }
232  }, {
233    key: "action",
234    set: function set() {
235      var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
236      this._action = action;
237
238      if (this._action !== 'copy' && this._action !== 'cut') {
239        throw new Error('Invalid "action" value, use either "copy" or "cut"');
240      }
241    }
242    /**
243     * Gets the `action` property.
244     * @return {String}
245     */
246    ,
247    get: function get() {
248      return this._action;
249    }
250    /**
251     * Sets the `target` property using an element
252     * that will be have its content copied.
253     * @param {Element} target
254     */
255
256  }, {
257    key: "target",
258    set: function set(target) {
259      if (target !== undefined) {
260        if (target && _typeof(target) === 'object' && target.nodeType === 1) {
261          if (this.action === 'copy' && target.hasAttribute('disabled')) {
262            throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
263          }
264
265          if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
266            throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
267          }
268
269          this._target = target;
270        } else {
271          throw new Error('Invalid "target" value, use a valid Element');
272        }
273      }
274    }
275    /**
276     * Gets the `target` property.
277     * @return {String|HTMLElement}
278     */
279    ,
280    get: function get() {
281      return this._target;
282    }
283  }]);
284
285  return ClipboardAction;
286}();
287
288/* harmony default export */ var clipboard_action = (ClipboardAction);
289;// CONCATENATED MODULE: ./src/clipboard.js
290function clipboard_typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { clipboard_typeof = function _typeof(obj) { return typeof obj; }; } else { clipboard_typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return clipboard_typeof(obj); }
291
292function clipboard_classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
293
294function clipboard_defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } }
295
296function clipboard_createClass(Constructor, protoProps, staticProps) { if (protoProps) clipboard_defineProperties(Constructor.prototype, protoProps); if (staticProps) clipboard_defineProperties(Constructor, staticProps); return Constructor; }
297
298function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }
299
300function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
301
302function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
303
304function _possibleConstructorReturn(self, call) { if (call && (clipboard_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
305
306function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
307
308function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
309
310function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
311
312
313
314
315/**
316 * Helper function to retrieve attribute value.
317 * @param {String} suffix
318 * @param {Element} element
319 */
320
321function getAttributeValue(suffix, element) {
322  var attribute = "data-clipboard-".concat(suffix);
323
324  if (!element.hasAttribute(attribute)) {
325    return;
326  }
327
328  return element.getAttribute(attribute);
329}
330/**
331 * Base class which takes one or more elements, adds event listeners to them,
332 * and instantiates a new `ClipboardAction` on each click.
333 */
334
335
336var Clipboard = /*#__PURE__*/function (_Emitter) {
337  _inherits(Clipboard, _Emitter);
338
339  var _super = _createSuper(Clipboard);
340
341  /**
342   * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
343   * @param {Object} options
344   */
345  function Clipboard(trigger, options) {
346    var _this;
347
348    clipboard_classCallCheck(this, Clipboard);
349
350    _this = _super.call(this);
351
352    _this.resolveOptions(options);
353
354    _this.listenClick(trigger);
355
356    return _this;
357  }
358  /**
359   * Defines if attributes would be resolved using internal setter functions
360   * or custom functions that were passed in the constructor.
361   * @param {Object} options
362   */
363
364
365  clipboard_createClass(Clipboard, [{
366    key: "resolveOptions",
367    value: function resolveOptions() {
368      var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
369      this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
370      this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
371      this.text = typeof options.text === 'function' ? options.text : this.defaultText;
372      this.container = clipboard_typeof(options.container) === 'object' ? options.container : document.body;
373    }
374    /**
375     * Adds a click event listener to the passed trigger.
376     * @param {String|HTMLElement|HTMLCollection|NodeList} trigger
377     */
378
379  }, {
380    key: "listenClick",
381    value: function listenClick(trigger) {
382      var _this2 = this;
383
384      this.listener = listen_default()(trigger, 'click', function (e) {
385        return _this2.onClick(e);
386      });
387    }
388    /**
389     * Defines a new `ClipboardAction` on each click event.
390     * @param {Event} e
391     */
392
393  }, {
394    key: "onClick",
395    value: function onClick(e) {
396      var trigger = e.delegateTarget || e.currentTarget;
397
398      if (this.clipboardAction) {
399        this.clipboardAction = null;
400      }
401
402      this.clipboardAction = new clipboard_action({
403        action: this.action(trigger),
404        target: this.target(trigger),
405        text: this.text(trigger),
406        container: this.container,
407        trigger: trigger,
408        emitter: this
409      });
410    }
411    /**
412     * Default `action` lookup function.
413     * @param {Element} trigger
414     */
415
416  }, {
417    key: "defaultAction",
418    value: function defaultAction(trigger) {
419      return getAttributeValue('action', trigger);
420    }
421    /**
422     * Default `target` lookup function.
423     * @param {Element} trigger
424     */
425
426  }, {
427    key: "defaultTarget",
428    value: function defaultTarget(trigger) {
429      var selector = getAttributeValue('target', trigger);
430
431      if (selector) {
432        return document.querySelector(selector);
433      }
434    }
435    /**
436     * Returns the support of the given action, or all actions if no action is
437     * given.
438     * @param {String} [action]
439     */
440
441  }, {
442    key: "defaultText",
443
444    /**
445     * Default `text` lookup function.
446     * @param {Element} trigger
447     */
448    value: function defaultText(trigger) {
449      return getAttributeValue('text', trigger);
450    }
451    /**
452     * Destroy lifecycle.
453     */
454
455  }, {
456    key: "destroy",
457    value: function destroy() {
458      this.listener.destroy();
459
460      if (this.clipboardAction) {
461        this.clipboardAction.destroy();
462        this.clipboardAction = null;
463      }
464    }
465  }], [{
466    key: "isSupported",
467    value: function isSupported() {
468      var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : ['copy', 'cut'];
469      var actions = typeof action === 'string' ? [action] : action;
470      var support = !!document.queryCommandSupported;
471      actions.forEach(function (action) {
472        support = support && !!document.queryCommandSupported(action);
473      });
474      return support;
475    }
476  }]);
477
478  return Clipboard;
479}((tiny_emitter_default()));
480
481/* harmony default export */ var clipboard = (Clipboard);
482
483/***/ }),
484
485/***/ 828:
486/***/ (function(module) {
487
488var DOCUMENT_NODE_TYPE = 9;
489
490/**
491 * A polyfill for Element.matches()
492 */
493if (typeof Element !== 'undefined' && !Element.prototype.matches) {
494    var proto = Element.prototype;
495
496    proto.matches = proto.matchesSelector ||
497                    proto.mozMatchesSelector ||
498                    proto.msMatchesSelector ||
499                    proto.oMatchesSelector ||
500                    proto.webkitMatchesSelector;
501}
502
503/**
504 * Finds the closest parent that matches a selector.
505 *
506 * @param {Element} element
507 * @param {String} selector
508 * @return {Function}
509 */
510function closest (element, selector) {
511    while (element && element.nodeType !== DOCUMENT_NODE_TYPE) {
512        if (typeof element.matches === 'function' &&
513            element.matches(selector)) {
514          return element;
515        }
516        element = element.parentNode;
517    }
518}
519
520module.exports = closest;
521
522
523/***/ }),
524
525/***/ 438:
526/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
527
528var closest = __webpack_require__(828);
529
530/**
531 * Delegates event to a selector.
532 *
533 * @param {Element} element
534 * @param {String} selector
535 * @param {String} type
536 * @param {Function} callback
537 * @param {Boolean} useCapture
538 * @return {Object}
539 */
540function _delegate(element, selector, type, callback, useCapture) {
541    var listenerFn = listener.apply(this, arguments);
542
543    element.addEventListener(type, listenerFn, useCapture);
544
545    return {
546        destroy: function() {
547            element.removeEventListener(type, listenerFn, useCapture);
548        }
549    }
550}
551
552/**
553 * Delegates event to a selector.
554 *
555 * @param {Element|String|Array} [elements]
556 * @param {String} selector
557 * @param {String} type
558 * @param {Function} callback
559 * @param {Boolean} useCapture
560 * @return {Object}
561 */
562function delegate(elements, selector, type, callback, useCapture) {
563    // Handle the regular Element usage
564    if (typeof elements.addEventListener === 'function') {
565        return _delegate.apply(null, arguments);
566    }
567
568    // Handle Element-less usage, it defaults to global delegation
569    if (typeof type === 'function') {
570        // Use `document` as the first parameter, then apply arguments
571        // This is a short way to .unshift `arguments` without running into deoptimizations
572        return _delegate.bind(null, document).apply(null, arguments);
573    }
574
575    // Handle Selector-based usage
576    if (typeof elements === 'string') {
577        elements = document.querySelectorAll(elements);
578    }
579
580    // Handle Array-like based usage
581    return Array.prototype.map.call(elements, function (element) {
582        return _delegate(element, selector, type, callback, useCapture);
583    });
584}
585
586/**
587 * Finds closest match and invokes callback.
588 *
589 * @param {Element} element
590 * @param {String} selector
591 * @param {String} type
592 * @param {Function} callback
593 * @return {Function}
594 */
595function listener(element, selector, type, callback) {
596    return function(e) {
597        e.delegateTarget = closest(e.target, selector);
598
599        if (e.delegateTarget) {
600            callback.call(element, e);
601        }
602    }
603}
604
605module.exports = delegate;
606
607
608/***/ }),
609
610/***/ 879:
611/***/ (function(__unused_webpack_module, exports) {
612
613/**
614 * Check if argument is a HTML element.
615 *
616 * @param {Object} value
617 * @return {Boolean}
618 */
619exports.node = function(value) {
620    return value !== undefined
621        && value instanceof HTMLElement
622        && value.nodeType === 1;
623};
624
625/**
626 * Check if argument is a list of HTML elements.
627 *
628 * @param {Object} value
629 * @return {Boolean}
630 */
631exports.nodeList = function(value) {
632    var type = Object.prototype.toString.call(value);
633
634    return value !== undefined
635        && (type === '[object NodeList]' || type === '[object HTMLCollection]')
636        && ('length' in value)
637        && (value.length === 0 || exports.node(value[0]));
638};
639
640/**
641 * Check if argument is a string.
642 *
643 * @param {Object} value
644 * @return {Boolean}
645 */
646exports.string = function(value) {
647    return typeof value === 'string'
648        || value instanceof String;
649};
650
651/**
652 * Check if argument is a function.
653 *
654 * @param {Object} value
655 * @return {Boolean}
656 */
657exports.fn = function(value) {
658    var type = Object.prototype.toString.call(value);
659
660    return type === '[object Function]';
661};
662
663
664/***/ }),
665
666/***/ 370:
667/***/ (function(module, __unused_webpack_exports, __webpack_require__) {
668
669var is = __webpack_require__(879);
670var delegate = __webpack_require__(438);
671
672/**
673 * Validates all params and calls the right
674 * listener function based on its target type.
675 *
676 * @param {String|HTMLElement|HTMLCollection|NodeList} target
677 * @param {String} type
678 * @param {Function} callback
679 * @return {Object}
680 */
681function listen(target, type, callback) {
682    if (!target && !type && !callback) {
683        throw new Error('Missing required arguments');
684    }
685
686    if (!is.string(type)) {
687        throw new TypeError('Second argument must be a String');
688    }
689
690    if (!is.fn(callback)) {
691        throw new TypeError('Third argument must be a Function');
692    }
693
694    if (is.node(target)) {
695        return listenNode(target, type, callback);
696    }
697    else if (is.nodeList(target)) {
698        return listenNodeList(target, type, callback);
699    }
700    else if (is.string(target)) {
701        return listenSelector(target, type, callback);
702    }
703    else {
704        throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
705    }
706}
707
708/**
709 * Adds an event listener to a HTML element
710 * and returns a remove listener function.
711 *
712 * @param {HTMLElement} node
713 * @param {String} type
714 * @param {Function} callback
715 * @return {Object}
716 */
717function listenNode(node, type, callback) {
718    node.addEventListener(type, callback);
719
720    return {
721        destroy: function() {
722            node.removeEventListener(type, callback);
723        }
724    }
725}
726
727/**
728 * Add an event listener to a list of HTML elements
729 * and returns a remove listener function.
730 *
731 * @param {NodeList|HTMLCollection} nodeList
732 * @param {String} type
733 * @param {Function} callback
734 * @return {Object}
735 */
736function listenNodeList(nodeList, type, callback) {
737    Array.prototype.forEach.call(nodeList, function(node) {
738        node.addEventListener(type, callback);
739    });
740
741    return {
742        destroy: function() {
743            Array.prototype.forEach.call(nodeList, function(node) {
744                node.removeEventListener(type, callback);
745            });
746        }
747    }
748}
749
750/**
751 * Add an event listener to a selector
752 * and returns a remove listener function.
753 *
754 * @param {String} selector
755 * @param {String} type
756 * @param {Function} callback
757 * @return {Object}
758 */
759function listenSelector(selector, type, callback) {
760    return delegate(document.body, selector, type, callback);
761}
762
763module.exports = listen;
764
765
766/***/ }),
767
768/***/ 817:
769/***/ (function(module) {
770
771function select(element) {
772    var selectedText;
773
774    if (element.nodeName === 'SELECT') {
775        element.focus();
776
777        selectedText = element.value;
778    }
779    else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
780        var isReadOnly = element.hasAttribute('readonly');
781
782        if (!isReadOnly) {
783            element.setAttribute('readonly', '');
784        }
785
786        element.select();
787        element.setSelectionRange(0, element.value.length);
788
789        if (!isReadOnly) {
790            element.removeAttribute('readonly');
791        }
792
793        selectedText = element.value;
794    }
795    else {
796        if (element.hasAttribute('contenteditable')) {
797            element.focus();
798        }
799
800        var selection = window.getSelection();
801        var range = document.createRange();
802
803        range.selectNodeContents(element);
804        selection.removeAllRanges();
805        selection.addRange(range);
806
807        selectedText = selection.toString();
808    }
809
810    return selectedText;
811}
812
813module.exports = select;
814
815
816/***/ }),
817
818/***/ 279:
819/***/ (function(module) {
820
821function E () {
822  // Keep this empty so it's easier to inherit from
823  // (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
824}
825
826E.prototype = {
827  on: function (name, callback, ctx) {
828    var e = this.e || (this.e = {});
829
830    (e[name] || (e[name] = [])).push({
831      fn: callback,
832      ctx: ctx
833    });
834
835    return this;
836  },
837
838  once: function (name, callback, ctx) {
839    var self = this;
840    function listener () {
841      self.off(name, listener);
842      callback.apply(ctx, arguments);
843    };
844
845    listener._ = callback
846    return this.on(name, listener, ctx);
847  },
848
849  emit: function (name) {
850    var data = [].slice.call(arguments, 1);
851    var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
852    var i = 0;
853    var len = evtArr.length;
854
855    for (i; i < len; i++) {
856      evtArr[i].fn.apply(evtArr[i].ctx, data);
857    }
858
859    return this;
860  },
861
862  off: function (name, callback) {
863    var e = this.e || (this.e = {});
864    var evts = e[name];
865    var liveEvents = [];
866
867    if (evts && callback) {
868      for (var i = 0, len = evts.length; i < len; i++) {
869        if (evts[i].fn !== callback && evts[i].fn._ !== callback)
870          liveEvents.push(evts[i]);
871      }
872    }
873
874    // Remove event from queue to prevent memory leak
875    // Suggested by https://github.com/lazd
876    // Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
877
878    (liveEvents.length)
879      ? e[name] = liveEvents
880      : delete e[name];
881
882    return this;
883  }
884};
885
886module.exports = E;
887module.exports.TinyEmitter = E;
888
889
890/***/ })
891
892/******/ 	});
893/************************************************************************/
894/******/ 	// The module cache
895/******/ 	var __webpack_module_cache__ = {};
896/******/ 	
897/******/ 	// The require function
898/******/ 	function __webpack_require__(moduleId) {
899/******/ 		// Check if module is in cache
900/******/ 		if(__webpack_module_cache__[moduleId]) {
901/******/ 			return __webpack_module_cache__[moduleId].exports;
902/******/ 		}
903/******/ 		// Create a new module (and put it into the cache)
904/******/ 		var module = __webpack_module_cache__[moduleId] = {
905/******/ 			// no module.id needed
906/******/ 			// no module.loaded needed
907/******/ 			exports: {}
908/******/ 		};
909/******/ 	
910/******/ 		// Execute the module function
911/******/ 		__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
912/******/ 	
913/******/ 		// Return the exports of the module
914/******/ 		return module.exports;
915/******/ 	}
916/******/ 	
917/************************************************************************/
918/******/ 	/* webpack/runtime/compat get default export */
919/******/ 	!function() {
920/******/ 		// getDefaultExport function for compatibility with non-harmony modules
921/******/ 		__webpack_require__.n = function(module) {
922/******/ 			var getter = module && module.__esModule ?
923/******/ 				function() { return module['default']; } :
924/******/ 				function() { return module; };
925/******/ 			__webpack_require__.d(getter, { a: getter });
926/******/ 			return getter;
927/******/ 		};
928/******/ 	}();
929/******/ 	
930/******/ 	/* webpack/runtime/define property getters */
931/******/ 	!function() {
932/******/ 		// define getter functions for harmony exports
933/******/ 		__webpack_require__.d = function(exports, definition) {
934/******/ 			for(var key in definition) {
935/******/ 				if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
936/******/ 					Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
937/******/ 				}
938/******/ 			}
939/******/ 		};
940/******/ 	}();
941/******/ 	
942/******/ 	/* webpack/runtime/hasOwnProperty shorthand */
943/******/ 	!function() {
944/******/ 		__webpack_require__.o = function(obj, prop) { return Object.prototype.hasOwnProperty.call(obj, prop); }
945/******/ 	}();
946/******/ 	
947/************************************************************************/
948/******/ 	// module exports must be returned from runtime so entry inlining is disabled
949/******/ 	// startup
950/******/ 	// Load entry module and return exports
951/******/ 	return __webpack_require__(134);
952/******/ })()
953.default;
954});