js-copy

copy

此腳本不應該直接安裝,它是一個供其他腳本使用的函式庫。欲使用本函式庫,請在腳本 metadata 寫上: // @require https://update.gf.qytechs.cn/scripts/439260/1013281/js-copy.js

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

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址