@lingxiteam/lcdp-ueditor-react 1.0.0-alpha.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/LcdpUeditor.d.ts +74 -0
- package/es/LcdpUeditor.js +335 -0
- package/es/const.d.ts +12 -0
- package/es/const.js +19 -0
- package/es/defaultConfig.json +77 -0
- package/es/index.d.ts +4 -0
- package/es/index.js +3 -0
- package/es/tools/UeditorResourceLoader.d.ts +21 -0
- package/es/tools/UeditorResourceLoader.js +114 -0
- package/es/tools/loadScript.d.ts +5 -0
- package/es/tools/loadScript.js +54 -0
- package/es/type.d.ts +142 -0
- package/es/type.js +1 -0
- package/package.json +32 -0
- package/ueditor-resource/dialogs/anchor/anchor.html +62 -0
- package/ueditor-resource/dialogs/attachment/attachment.css +716 -0
- package/ueditor-resource/dialogs/attachment/attachment.html +61 -0
- package/ueditor-resource/dialogs/attachment/attachment.js +803 -0
- package/ueditor-resource/dialogs/attachment/images/alignicon.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/alignicon.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/bg.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/icons.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/image.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/progress.png +0 -0
- package/ueditor-resource/dialogs/attachment/images/success.gif +0 -0
- package/ueditor-resource/dialogs/attachment/images/success.png +0 -0
- package/ueditor-resource/dialogs/audio/audio.css +879 -0
- package/ueditor-resource/dialogs/audio/audio.html +94 -0
- package/ueditor-resource/dialogs/audio/audio.js +815 -0
- package/ueditor-resource/dialogs/audio/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/center.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/img.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/left.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/none.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/audio/icon/right.png +0 -0
- package/ueditor-resource/dialogs/audio/images/bg.png +0 -0
- package/ueditor-resource/dialogs/audio/images/center_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/audio/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/icons.png +0 -0
- package/ueditor-resource/dialogs/audio/images/image.png +0 -0
- package/ueditor-resource/dialogs/audio/images/left_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/none_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/progress.png +0 -0
- package/ueditor-resource/dialogs/audio/images/right_focus.jpg +0 -0
- package/ueditor-resource/dialogs/audio/images/success.gif +0 -0
- package/ueditor-resource/dialogs/audio/images/success.png +0 -0
- package/ueditor-resource/dialogs/background/background.css +193 -0
- package/ueditor-resource/dialogs/background/background.html +59 -0
- package/ueditor-resource/dialogs/background/background.js +370 -0
- package/ueditor-resource/dialogs/background/images/bg.png +0 -0
- package/ueditor-resource/dialogs/background/images/success.png +0 -0
- package/ueditor-resource/dialogs/contentimport/contentimport.html +176 -0
- package/ueditor-resource/dialogs/contentimport/contentimport.js +91 -0
- package/ueditor-resource/dialogs/emotion/emotion.css +129 -0
- package/ueditor-resource/dialogs/emotion/emotion.html +70 -0
- package/ueditor-resource/dialogs/emotion/emotion.js +186 -0
- package/ueditor-resource/dialogs/emotion/images/0.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/bface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/cface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/fface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/jxface2.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/neweditor-tab-bg.png +0 -0
- package/ueditor-resource/dialogs/emotion/images/tface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/wface.gif +0 -0
- package/ueditor-resource/dialogs/emotion/images/yface.gif +0 -0
- package/ueditor-resource/dialogs/formula/formula.html +98 -0
- package/ueditor-resource/dialogs/formula/formula.js +147 -0
- package/ueditor-resource/dialogs/help/help.css +37 -0
- package/ueditor-resource/dialogs/help/help.html +82 -0
- package/ueditor-resource/dialogs/help/help.js +57 -0
- package/ueditor-resource/dialogs/image/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/center.png +0 -0
- package/ueditor-resource/dialogs/image/icon/img.png +0 -0
- package/ueditor-resource/dialogs/image/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/left.png +0 -0
- package/ueditor-resource/dialogs/image/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/none.png +0 -0
- package/ueditor-resource/dialogs/image/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/image/icon/right.png +0 -0
- package/ueditor-resource/dialogs/image/image.css +768 -0
- package/ueditor-resource/dialogs/image/image.html +145 -0
- package/ueditor-resource/dialogs/image/image.js +1060 -0
- package/ueditor-resource/dialogs/image/images/alignicon.jpg +0 -0
- package/ueditor-resource/dialogs/image/images/bg.png +0 -0
- package/ueditor-resource/dialogs/image/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/image/images/icons.png +0 -0
- package/ueditor-resource/dialogs/image/images/image.png +0 -0
- package/ueditor-resource/dialogs/image/images/progress.png +0 -0
- package/ueditor-resource/dialogs/image/images/success.gif +0 -0
- package/ueditor-resource/dialogs/image/images/success.png +0 -0
- package/ueditor-resource/dialogs/insertframe/insertframe.html +135 -0
- package/ueditor-resource/dialogs/internal.js +81 -0
- package/ueditor-resource/dialogs/link/link.html +148 -0
- package/ueditor-resource/dialogs/preview/preview.html +45 -0
- package/ueditor-resource/dialogs/scrawl/images/addimg.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/brush.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/delimg.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/delimgH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/empty.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/emptyH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/eraser.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/redo.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/redoH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/scale.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/scaleH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/size.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/undo.png +0 -0
- package/ueditor-resource/dialogs/scrawl/images/undoH.png +0 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.css +324 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.html +95 -0
- package/ueditor-resource/dialogs/scrawl/scrawl.js +682 -0
- package/ueditor-resource/dialogs/searchreplace/searchreplace.html +144 -0
- package/ueditor-resource/dialogs/searchreplace/searchreplace.js +174 -0
- package/ueditor-resource/dialogs/spechars/spechars.html +42 -0
- package/ueditor-resource/dialogs/spechars/spechars.js +86 -0
- package/ueditor-resource/dialogs/table/dragicon.png +0 -0
- package/ueditor-resource/dialogs/table/edittable.css +85 -0
- package/ueditor-resource/dialogs/table/edittable.html +69 -0
- package/ueditor-resource/dialogs/table/edittable.js +241 -0
- package/ueditor-resource/dialogs/table/edittd.html +62 -0
- package/ueditor-resource/dialogs/table/edittip.html +33 -0
- package/ueditor-resource/dialogs/template/config.js +42 -0
- package/ueditor-resource/dialogs/template/images/bg.gif +0 -0
- package/ueditor-resource/dialogs/template/images/pre0.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre1.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre2.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre3.png +0 -0
- package/ueditor-resource/dialogs/template/images/pre4.png +0 -0
- package/ueditor-resource/dialogs/template/template.css +99 -0
- package/ueditor-resource/dialogs/template/template.html +26 -0
- package/ueditor-resource/dialogs/template/template.js +53 -0
- package/ueditor-resource/dialogs/video/icon/center-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/center.png +0 -0
- package/ueditor-resource/dialogs/video/icon/img.png +0 -0
- package/ueditor-resource/dialogs/video/icon/left-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/left.png +0 -0
- package/ueditor-resource/dialogs/video/icon/none-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/none.png +0 -0
- package/ueditor-resource/dialogs/video/icon/right-active.png +0 -0
- package/ueditor-resource/dialogs/video/icon/right.png +0 -0
- package/ueditor-resource/dialogs/video/images/bg.png +0 -0
- package/ueditor-resource/dialogs/video/images/center_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/file-icons.gif +0 -0
- package/ueditor-resource/dialogs/video/images/file-icons.png +0 -0
- package/ueditor-resource/dialogs/video/images/icons.gif +0 -0
- package/ueditor-resource/dialogs/video/images/icons.png +0 -0
- package/ueditor-resource/dialogs/video/images/image.png +0 -0
- package/ueditor-resource/dialogs/video/images/left_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/none_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/progress.png +0 -0
- package/ueditor-resource/dialogs/video/images/right_focus.jpg +0 -0
- package/ueditor-resource/dialogs/video/images/success.gif +0 -0
- package/ueditor-resource/dialogs/video/images/success.png +0 -0
- package/ueditor-resource/dialogs/video/video.css +909 -0
- package/ueditor-resource/dialogs/video/video.html +115 -0
- package/ueditor-resource/dialogs/video/video.js +867 -0
- package/ueditor-resource/dialogs/wordimage/wordimage.html +221 -0
- package/ueditor-resource/dialogs/wordimage/wordimage.js +93 -0
- package/ueditor-resource/index.html +146 -0
- package/ueditor-resource/lang/en/en.js +686 -0
- package/ueditor-resource/lang/en/images/addimage.png +0 -0
- package/ueditor-resource/lang/en/images/alldeletebtnhoverskin.png +0 -0
- package/ueditor-resource/lang/en/images/alldeletebtnupskin.png +0 -0
- package/ueditor-resource/lang/en/images/background.png +0 -0
- package/ueditor-resource/lang/en/images/button.png +0 -0
- package/ueditor-resource/lang/en/images/copy.png +0 -0
- package/ueditor-resource/lang/en/images/deletedisable.png +0 -0
- package/ueditor-resource/lang/en/images/deleteenable.png +0 -0
- package/ueditor-resource/lang/en/images/listbackground.png +0 -0
- package/ueditor-resource/lang/en/images/localimage.png +0 -0
- package/ueditor-resource/lang/en/images/music.png +0 -0
- package/ueditor-resource/lang/en/images/rotateleftdisable.png +0 -0
- package/ueditor-resource/lang/en/images/rotateleftenable.png +0 -0
- package/ueditor-resource/lang/en/images/rotaterightdisable.png +0 -0
- package/ueditor-resource/lang/en/images/rotaterightenable.png +0 -0
- package/ueditor-resource/lang/en/images/upload.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/copy.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/localimage.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/music.png +0 -0
- package/ueditor-resource/lang/zh-cn/images/upload.png +0 -0
- package/ueditor-resource/lang/zh-cn/zh-cn.js +748 -0
- package/ueditor-resource/plugins/demo/demo.js +3 -0
- package/ueditor-resource/themes/default/css/ueditor.css +2148 -0
- package/ueditor-resource/themes/default/dialog.css +17 -0
- package/ueditor-resource/themes/default/dialogbase.css +132 -0
- package/ueditor-resource/themes/default/exts/ai.svg +12 -0
- package/ueditor-resource/themes/default/exts/apk.svg +12 -0
- package/ueditor-resource/themes/default/exts/chm.svg +12 -0
- package/ueditor-resource/themes/default/exts/css.svg +12 -0
- package/ueditor-resource/themes/default/exts/doc.svg +22 -0
- package/ueditor-resource/themes/default/exts/docx.svg +22 -0
- package/ueditor-resource/themes/default/exts/dwg.svg +16 -0
- package/ueditor-resource/themes/default/exts/folder.svg +3 -0
- package/ueditor-resource/themes/default/exts/gif.svg +14 -0
- package/ueditor-resource/themes/default/exts/html.svg +12 -0
- package/ueditor-resource/themes/default/exts/jpeg.svg +14 -0
- package/ueditor-resource/themes/default/exts/jpg.svg +14 -0
- package/ueditor-resource/themes/default/exts/log.svg +12 -0
- package/ueditor-resource/themes/default/exts/mp3.svg +14 -0
- package/ueditor-resource/themes/default/exts/mp4.svg +12 -0
- package/ueditor-resource/themes/default/exts/pdf.svg +14 -0
- package/ueditor-resource/themes/default/exts/png.svg +14 -0
- package/ueditor-resource/themes/default/exts/ppt.svg +24 -0
- package/ueditor-resource/themes/default/exts/pptx.svg +24 -0
- package/ueditor-resource/themes/default/exts/psd.svg +12 -0
- package/ueditor-resource/themes/default/exts/rar.svg +12 -0
- package/ueditor-resource/themes/default/exts/svg.svg +12 -0
- package/ueditor-resource/themes/default/exts/torrent.svg +14 -0
- package/ueditor-resource/themes/default/exts/txt.svg +14 -0
- package/ueditor-resource/themes/default/exts/unknown.svg +12 -0
- package/ueditor-resource/themes/default/exts/xls.svg +25 -0
- package/ueditor-resource/themes/default/exts/xlsx.svg +25 -0
- package/ueditor-resource/themes/default/exts/zip.svg +12 -0
- package/ueditor-resource/themes/default/images/anchor.gif +0 -0
- package/ueditor-resource/themes/default/images/arrow.png +0 -0
- package/ueditor-resource/themes/default/images/arrow_down.png +0 -0
- package/ueditor-resource/themes/default/images/arrow_up.png +0 -0
- package/ueditor-resource/themes/default/images/button-bg.gif +0 -0
- package/ueditor-resource/themes/default/images/cancelbutton.gif +0 -0
- package/ueditor-resource/themes/default/images/charts.png +0 -0
- package/ueditor-resource/themes/default/images/cursor_h.gif +0 -0
- package/ueditor-resource/themes/default/images/cursor_h.png +0 -0
- package/ueditor-resource/themes/default/images/cursor_v.gif +0 -0
- package/ueditor-resource/themes/default/images/cursor_v.png +0 -0
- package/ueditor-resource/themes/default/images/dialog-title-bg.png +0 -0
- package/ueditor-resource/themes/default/images/filescan.png +0 -0
- package/ueditor-resource/themes/default/images/highlighted.gif +0 -0
- package/ueditor-resource/themes/default/images/icons-all.gif +0 -0
- package/ueditor-resource/themes/default/images/icons.gif +0 -0
- package/ueditor-resource/themes/default/images/icons.png +0 -0
- package/ueditor-resource/themes/default/images/img-cracked.png +0 -0
- package/ueditor-resource/themes/default/images/loaderror.png +0 -0
- package/ueditor-resource/themes/default/images/loading.gif +0 -0
- package/ueditor-resource/themes/default/images/lock.gif +0 -0
- package/ueditor-resource/themes/default/images/neweditor-tab-bg.png +0 -0
- package/ueditor-resource/themes/default/images/pagebreak.gif +0 -0
- package/ueditor-resource/themes/default/images/scale.png +0 -0
- package/ueditor-resource/themes/default/images/sortable.png +0 -0
- package/ueditor-resource/themes/default/images/spacer.gif +0 -0
- package/ueditor-resource/themes/default/images/sparator_v.png +0 -0
- package/ueditor-resource/themes/default/images/table-cell-align.png +0 -0
- package/ueditor-resource/themes/default/images/tangram-colorpicker.png +0 -0
- package/ueditor-resource/themes/default/images/toolbar_bg.png +0 -0
- package/ueditor-resource/themes/default/images/unhighlighted.gif +0 -0
- package/ueditor-resource/themes/default/images/upload.png +0 -0
- package/ueditor-resource/themes/default/images/videologo.gif +0 -0
- package/ueditor-resource/themes/default/images/word.gif +0 -0
- package/ueditor-resource/themes/default/images/wordpaste.png +0 -0
- package/ueditor-resource/themes/iframe.css +63 -0
- package/ueditor-resource/third-party/SyntaxHighlighter/shCore.js +3655 -0
- package/ueditor-resource/third-party/SyntaxHighlighter/shCoreDefault.css +1 -0
- package/ueditor-resource/third-party/clipboard/clipboard.js +753 -0
- package/ueditor-resource/third-party/clipboard/clipboard.swf +0 -0
- package/ueditor-resource/third-party/codemirror/codemirror.css +106 -0
- package/ueditor-resource/third-party/codemirror/codemirror.js +3581 -0
- package/ueditor-resource/third-party/jquery-3.5.1.js +2 -0
- package/ueditor-resource/third-party/jquery-3.5.1_1.js +4314 -0
- package/ueditor-resource/third-party/webuploader/webuploader.css +88 -0
- package/ueditor-resource/third-party/webuploader/webuploader.js +4 -0
- package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.js +1256 -0
- package/ueditor-resource/third-party/zeroclipboard/ZeroClipboard.swf +0 -0
- package/ueditor-resource/ueditor.all.js +32643 -0
- package/ueditor-resource/ueditor.config.js +656 -0
- package/ueditor-resource/ueditor.parse.js +639 -0
|
@@ -0,0 +1,753 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* clipboard.js v1.5.15
|
|
3
|
+
* https://zenorocha.github.io/clipboard.js
|
|
4
|
+
*
|
|
5
|
+
* Licensed MIT © Zeno Rocha
|
|
6
|
+
*/
|
|
7
|
+
(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.Clipboard = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
|
|
8
|
+
/**
|
|
9
|
+
* A polyfill for Element.matches()
|
|
10
|
+
*/
|
|
11
|
+
if (Element && !Element.prototype.matches) {
|
|
12
|
+
var proto = Element.prototype;
|
|
13
|
+
|
|
14
|
+
proto.matches = proto.matchesSelector ||
|
|
15
|
+
proto.mozMatchesSelector ||
|
|
16
|
+
proto.msMatchesSelector ||
|
|
17
|
+
proto.oMatchesSelector ||
|
|
18
|
+
proto.webkitMatchesSelector;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Finds the closest parent that matches a selector.
|
|
23
|
+
*
|
|
24
|
+
* @param {Element} element
|
|
25
|
+
* @param {String} selector
|
|
26
|
+
* @return {Function}
|
|
27
|
+
*/
|
|
28
|
+
function closest (element, selector) {
|
|
29
|
+
while (element && element !== document) {
|
|
30
|
+
if (element.matches(selector)) return element;
|
|
31
|
+
element = element.parentNode;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
module.exports = closest;
|
|
36
|
+
|
|
37
|
+
},{}],2:[function(require,module,exports){
|
|
38
|
+
var closest = require('./closest');
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* Delegates event to a selector.
|
|
42
|
+
*
|
|
43
|
+
* @param {Element} element
|
|
44
|
+
* @param {String} selector
|
|
45
|
+
* @param {String} type
|
|
46
|
+
* @param {Function} callback
|
|
47
|
+
* @param {Boolean} useCapture
|
|
48
|
+
* @return {Object}
|
|
49
|
+
*/
|
|
50
|
+
function delegate(element, selector, type, callback, useCapture) {
|
|
51
|
+
var listenerFn = listener.apply(this, arguments);
|
|
52
|
+
|
|
53
|
+
element.addEventListener(type, listenerFn, useCapture);
|
|
54
|
+
|
|
55
|
+
return {
|
|
56
|
+
destroy: function() {
|
|
57
|
+
element.removeEventListener(type, listenerFn, useCapture);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Finds closest match and invokes callback.
|
|
64
|
+
*
|
|
65
|
+
* @param {Element} element
|
|
66
|
+
* @param {String} selector
|
|
67
|
+
* @param {String} type
|
|
68
|
+
* @param {Function} callback
|
|
69
|
+
* @return {Function}
|
|
70
|
+
*/
|
|
71
|
+
function listener(element, selector, type, callback) {
|
|
72
|
+
return function(e) {
|
|
73
|
+
e.delegateTarget = closest(e.target, selector);
|
|
74
|
+
|
|
75
|
+
if (e.delegateTarget) {
|
|
76
|
+
callback.call(element, e);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = delegate;
|
|
82
|
+
|
|
83
|
+
},{"./closest":1}],3:[function(require,module,exports){
|
|
84
|
+
/**
|
|
85
|
+
* Check if argument is a HTML element.
|
|
86
|
+
*
|
|
87
|
+
* @param {Object} value
|
|
88
|
+
* @return {Boolean}
|
|
89
|
+
*/
|
|
90
|
+
exports.node = function(value) {
|
|
91
|
+
return value !== undefined
|
|
92
|
+
&& value instanceof HTMLElement
|
|
93
|
+
&& value.nodeType === 1;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* Check if argument is a list of HTML elements.
|
|
98
|
+
*
|
|
99
|
+
* @param {Object} value
|
|
100
|
+
* @return {Boolean}
|
|
101
|
+
*/
|
|
102
|
+
exports.nodeList = function(value) {
|
|
103
|
+
var type = Object.prototype.toString.call(value);
|
|
104
|
+
|
|
105
|
+
return value !== undefined
|
|
106
|
+
&& (type === '[object NodeList]' || type === '[object HTMLCollection]')
|
|
107
|
+
&& ('length' in value)
|
|
108
|
+
&& (value.length === 0 || exports.node(value[0]));
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check if argument is a string.
|
|
113
|
+
*
|
|
114
|
+
* @param {Object} value
|
|
115
|
+
* @return {Boolean}
|
|
116
|
+
*/
|
|
117
|
+
exports.string = function(value) {
|
|
118
|
+
return typeof value === 'string'
|
|
119
|
+
|| value instanceof String;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Check if argument is a function.
|
|
124
|
+
*
|
|
125
|
+
* @param {Object} value
|
|
126
|
+
* @return {Boolean}
|
|
127
|
+
*/
|
|
128
|
+
exports.fn = function(value) {
|
|
129
|
+
var type = Object.prototype.toString.call(value);
|
|
130
|
+
|
|
131
|
+
return type === '[object Function]';
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
},{}],4:[function(require,module,exports){
|
|
135
|
+
var is = require('./is');
|
|
136
|
+
var delegate = require('delegate');
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* Validates all params and calls the right
|
|
140
|
+
* listener function based on its target type.
|
|
141
|
+
*
|
|
142
|
+
* @param {String|HTMLElement|HTMLCollection|NodeList} target
|
|
143
|
+
* @param {String} type
|
|
144
|
+
* @param {Function} callback
|
|
145
|
+
* @return {Object}
|
|
146
|
+
*/
|
|
147
|
+
function listen(target, type, callback) {
|
|
148
|
+
if (!target && !type && !callback) {
|
|
149
|
+
throw new Error('Missing required arguments');
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
if (!is.string(type)) {
|
|
153
|
+
throw new TypeError('Second argument must be a String');
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
if (!is.fn(callback)) {
|
|
157
|
+
throw new TypeError('Third argument must be a Function');
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
if (is.node(target)) {
|
|
161
|
+
return listenNode(target, type, callback);
|
|
162
|
+
}
|
|
163
|
+
else if (is.nodeList(target)) {
|
|
164
|
+
return listenNodeList(target, type, callback);
|
|
165
|
+
}
|
|
166
|
+
else if (is.string(target)) {
|
|
167
|
+
return listenSelector(target, type, callback);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
throw new TypeError('First argument must be a String, HTMLElement, HTMLCollection, or NodeList');
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
/**
|
|
175
|
+
* Adds an event listener to a HTML element
|
|
176
|
+
* and returns a remove listener function.
|
|
177
|
+
*
|
|
178
|
+
* @param {HTMLElement} node
|
|
179
|
+
* @param {String} type
|
|
180
|
+
* @param {Function} callback
|
|
181
|
+
* @return {Object}
|
|
182
|
+
*/
|
|
183
|
+
function listenNode(node, type, callback) {
|
|
184
|
+
node.addEventListener(type, callback);
|
|
185
|
+
|
|
186
|
+
return {
|
|
187
|
+
destroy: function() {
|
|
188
|
+
node.removeEventListener(type, callback);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Add an event listener to a list of HTML elements
|
|
195
|
+
* and returns a remove listener function.
|
|
196
|
+
*
|
|
197
|
+
* @param {NodeList|HTMLCollection} nodeList
|
|
198
|
+
* @param {String} type
|
|
199
|
+
* @param {Function} callback
|
|
200
|
+
* @return {Object}
|
|
201
|
+
*/
|
|
202
|
+
function listenNodeList(nodeList, type, callback) {
|
|
203
|
+
Array.prototype.forEach.call(nodeList, function(node) {
|
|
204
|
+
node.addEventListener(type, callback);
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
return {
|
|
208
|
+
destroy: function() {
|
|
209
|
+
Array.prototype.forEach.call(nodeList, function(node) {
|
|
210
|
+
node.removeEventListener(type, callback);
|
|
211
|
+
});
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Add an event listener to a selector
|
|
218
|
+
* and returns a remove listener function.
|
|
219
|
+
*
|
|
220
|
+
* @param {String} selector
|
|
221
|
+
* @param {String} type
|
|
222
|
+
* @param {Function} callback
|
|
223
|
+
* @return {Object}
|
|
224
|
+
*/
|
|
225
|
+
function listenSelector(selector, type, callback) {
|
|
226
|
+
return delegate(document.body, selector, type, callback);
|
|
227
|
+
}
|
|
228
|
+
|
|
229
|
+
module.exports = listen;
|
|
230
|
+
|
|
231
|
+
},{"./is":3,"delegate":2}],5:[function(require,module,exports){
|
|
232
|
+
function select(element) {
|
|
233
|
+
var selectedText;
|
|
234
|
+
|
|
235
|
+
if (element.nodeName === 'SELECT') {
|
|
236
|
+
element.focus();
|
|
237
|
+
|
|
238
|
+
selectedText = element.value;
|
|
239
|
+
}
|
|
240
|
+
else if (element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') {
|
|
241
|
+
element.focus();
|
|
242
|
+
element.setSelectionRange(0, element.value.length);
|
|
243
|
+
|
|
244
|
+
selectedText = element.value;
|
|
245
|
+
}
|
|
246
|
+
else {
|
|
247
|
+
if (element.hasAttribute('contenteditable')) {
|
|
248
|
+
element.focus();
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
var selection = window.getSelection();
|
|
252
|
+
var range = document.createRange();
|
|
253
|
+
|
|
254
|
+
range.selectNodeContents(element);
|
|
255
|
+
selection.removeAllRanges();
|
|
256
|
+
selection.addRange(range);
|
|
257
|
+
|
|
258
|
+
selectedText = selection.toString();
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
return selectedText;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
module.exports = select;
|
|
265
|
+
|
|
266
|
+
},{}],6:[function(require,module,exports){
|
|
267
|
+
function E () {
|
|
268
|
+
// Keep this empty so it's easier to inherit from
|
|
269
|
+
// (via https://github.com/lipsmack from https://github.com/scottcorgan/tiny-emitter/issues/3)
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
E.prototype = {
|
|
273
|
+
on: function (name, callback, ctx) {
|
|
274
|
+
var e = this.e || (this.e = {});
|
|
275
|
+
|
|
276
|
+
(e[name] || (e[name] = [])).push({
|
|
277
|
+
fn: callback,
|
|
278
|
+
ctx: ctx
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
return this;
|
|
282
|
+
},
|
|
283
|
+
|
|
284
|
+
once: function (name, callback, ctx) {
|
|
285
|
+
var self = this;
|
|
286
|
+
function listener () {
|
|
287
|
+
self.off(name, listener);
|
|
288
|
+
callback.apply(ctx, arguments);
|
|
289
|
+
};
|
|
290
|
+
|
|
291
|
+
listener._ = callback
|
|
292
|
+
return this.on(name, listener, ctx);
|
|
293
|
+
},
|
|
294
|
+
|
|
295
|
+
emit: function (name) {
|
|
296
|
+
var data = [].slice.call(arguments, 1);
|
|
297
|
+
var evtArr = ((this.e || (this.e = {}))[name] || []).slice();
|
|
298
|
+
var i = 0;
|
|
299
|
+
var len = evtArr.length;
|
|
300
|
+
|
|
301
|
+
for (i; i < len; i++) {
|
|
302
|
+
evtArr[i].fn.apply(evtArr[i].ctx, data);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
return this;
|
|
306
|
+
},
|
|
307
|
+
|
|
308
|
+
off: function (name, callback) {
|
|
309
|
+
var e = this.e || (this.e = {});
|
|
310
|
+
var evts = e[name];
|
|
311
|
+
var liveEvents = [];
|
|
312
|
+
|
|
313
|
+
if (evts && callback) {
|
|
314
|
+
for (var i = 0, len = evts.length; i < len; i++) {
|
|
315
|
+
if (evts[i].fn !== callback && evts[i].fn._ !== callback)
|
|
316
|
+
liveEvents.push(evts[i]);
|
|
317
|
+
}
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
// Remove event from queue to prevent memory leak
|
|
321
|
+
// Suggested by https://github.com/lazd
|
|
322
|
+
// Ref: https://github.com/scottcorgan/tiny-emitter/commit/c6ebfaa9bc973b33d110a84a307742b7cf94c953#commitcomment-5024910
|
|
323
|
+
|
|
324
|
+
(liveEvents.length)
|
|
325
|
+
? e[name] = liveEvents
|
|
326
|
+
: delete e[name];
|
|
327
|
+
|
|
328
|
+
return this;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
|
|
332
|
+
module.exports = E;
|
|
333
|
+
|
|
334
|
+
},{}],7:[function(require,module,exports){
|
|
335
|
+
(function (global, factory) {
|
|
336
|
+
if (typeof define === "function" && define.amd) {
|
|
337
|
+
define(['module', 'select'], factory);
|
|
338
|
+
} else if (typeof exports !== "undefined") {
|
|
339
|
+
factory(module, require('select'));
|
|
340
|
+
} else {
|
|
341
|
+
var mod = {
|
|
342
|
+
exports: {}
|
|
343
|
+
};
|
|
344
|
+
factory(mod, global.select);
|
|
345
|
+
global.clipboardAction = mod.exports;
|
|
346
|
+
}
|
|
347
|
+
})(this, function (module, _select) {
|
|
348
|
+
'use strict';
|
|
349
|
+
|
|
350
|
+
var _select2 = _interopRequireDefault(_select);
|
|
351
|
+
|
|
352
|
+
function _interopRequireDefault(obj) {
|
|
353
|
+
return obj && obj.__esModule ? obj : {
|
|
354
|
+
default: obj
|
|
355
|
+
};
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) {
|
|
359
|
+
return typeof obj;
|
|
360
|
+
} : function (obj) {
|
|
361
|
+
return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
|
|
362
|
+
};
|
|
363
|
+
|
|
364
|
+
function _classCallCheck(instance, Constructor) {
|
|
365
|
+
if (!(instance instanceof Constructor)) {
|
|
366
|
+
throw new TypeError("Cannot call a class as a function");
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
var _createClass = function () {
|
|
371
|
+
function defineProperties(target, props) {
|
|
372
|
+
for (var i = 0; i < props.length; i++) {
|
|
373
|
+
var descriptor = props[i];
|
|
374
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
375
|
+
descriptor.configurable = true;
|
|
376
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
377
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
378
|
+
}
|
|
379
|
+
}
|
|
380
|
+
|
|
381
|
+
return function (Constructor, protoProps, staticProps) {
|
|
382
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
383
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
384
|
+
return Constructor;
|
|
385
|
+
};
|
|
386
|
+
}();
|
|
387
|
+
|
|
388
|
+
var ClipboardAction = function () {
|
|
389
|
+
/**
|
|
390
|
+
* @param {Object} options
|
|
391
|
+
*/
|
|
392
|
+
function ClipboardAction(options) {
|
|
393
|
+
_classCallCheck(this, ClipboardAction);
|
|
394
|
+
|
|
395
|
+
this.resolveOptions(options);
|
|
396
|
+
this.initSelection();
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/**
|
|
400
|
+
* Defines base properties passed from constructor.
|
|
401
|
+
* @param {Object} options
|
|
402
|
+
*/
|
|
403
|
+
|
|
404
|
+
|
|
405
|
+
_createClass(ClipboardAction, [{
|
|
406
|
+
key: 'resolveOptions',
|
|
407
|
+
value: function resolveOptions() {
|
|
408
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
409
|
+
|
|
410
|
+
this.action = options.action;
|
|
411
|
+
this.emitter = options.emitter;
|
|
412
|
+
this.target = options.target;
|
|
413
|
+
this.text = options.text;
|
|
414
|
+
this.trigger = options.trigger;
|
|
415
|
+
|
|
416
|
+
this.selectedText = '';
|
|
417
|
+
}
|
|
418
|
+
}, {
|
|
419
|
+
key: 'initSelection',
|
|
420
|
+
value: function initSelection() {
|
|
421
|
+
if (this.text) {
|
|
422
|
+
this.selectFake();
|
|
423
|
+
} else if (this.target) {
|
|
424
|
+
this.selectTarget();
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}, {
|
|
428
|
+
key: 'selectFake',
|
|
429
|
+
value: function selectFake() {
|
|
430
|
+
var _this = this;
|
|
431
|
+
|
|
432
|
+
var isRTL = document.documentElement.getAttribute('dir') == 'rtl';
|
|
433
|
+
|
|
434
|
+
this.removeFake();
|
|
435
|
+
|
|
436
|
+
this.fakeHandlerCallback = function () {
|
|
437
|
+
return _this.removeFake();
|
|
438
|
+
};
|
|
439
|
+
this.fakeHandler = document.body.addEventListener('click', this.fakeHandlerCallback) || true;
|
|
440
|
+
|
|
441
|
+
this.fakeElem = document.createElement('textarea');
|
|
442
|
+
// Prevent zooming on iOS
|
|
443
|
+
this.fakeElem.style.fontSize = '12pt';
|
|
444
|
+
// Reset box model
|
|
445
|
+
this.fakeElem.style.border = '0';
|
|
446
|
+
this.fakeElem.style.padding = '0';
|
|
447
|
+
this.fakeElem.style.margin = '0';
|
|
448
|
+
// Move element out of screen horizontally
|
|
449
|
+
this.fakeElem.style.position = 'absolute';
|
|
450
|
+
this.fakeElem.style[isRTL ? 'right' : 'left'] = '-9999px';
|
|
451
|
+
// Move element to the same position vertically
|
|
452
|
+
var yPosition = window.pageYOffset || document.documentElement.scrollTop;
|
|
453
|
+
this.fakeElem.addEventListener('focus', window.scrollTo(0, yPosition));
|
|
454
|
+
this.fakeElem.style.top = yPosition + 'px';
|
|
455
|
+
|
|
456
|
+
this.fakeElem.setAttribute('readonly', '');
|
|
457
|
+
this.fakeElem.value = this.text;
|
|
458
|
+
|
|
459
|
+
document.body.appendChild(this.fakeElem);
|
|
460
|
+
|
|
461
|
+
this.selectedText = (0, _select2.default)(this.fakeElem);
|
|
462
|
+
this.copyText();
|
|
463
|
+
}
|
|
464
|
+
}, {
|
|
465
|
+
key: 'removeFake',
|
|
466
|
+
value: function removeFake() {
|
|
467
|
+
if (this.fakeHandler) {
|
|
468
|
+
document.body.removeEventListener('click', this.fakeHandlerCallback);
|
|
469
|
+
this.fakeHandler = null;
|
|
470
|
+
this.fakeHandlerCallback = null;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
if (this.fakeElem) {
|
|
474
|
+
document.body.removeChild(this.fakeElem);
|
|
475
|
+
this.fakeElem = null;
|
|
476
|
+
}
|
|
477
|
+
}
|
|
478
|
+
}, {
|
|
479
|
+
key: 'selectTarget',
|
|
480
|
+
value: function selectTarget() {
|
|
481
|
+
this.selectedText = (0, _select2.default)(this.target);
|
|
482
|
+
this.copyText();
|
|
483
|
+
}
|
|
484
|
+
}, {
|
|
485
|
+
key: 'copyText',
|
|
486
|
+
value: function copyText() {
|
|
487
|
+
var succeeded = void 0;
|
|
488
|
+
|
|
489
|
+
try {
|
|
490
|
+
succeeded = document.execCommand(this.action);
|
|
491
|
+
} catch (err) {
|
|
492
|
+
succeeded = false;
|
|
493
|
+
}
|
|
494
|
+
|
|
495
|
+
this.handleResult(succeeded);
|
|
496
|
+
}
|
|
497
|
+
}, {
|
|
498
|
+
key: 'handleResult',
|
|
499
|
+
value: function handleResult(succeeded) {
|
|
500
|
+
this.emitter.emit(succeeded ? 'success' : 'error', {
|
|
501
|
+
action: this.action,
|
|
502
|
+
text: this.selectedText,
|
|
503
|
+
trigger: this.trigger,
|
|
504
|
+
clearSelection: this.clearSelection.bind(this)
|
|
505
|
+
});
|
|
506
|
+
}
|
|
507
|
+
}, {
|
|
508
|
+
key: 'clearSelection',
|
|
509
|
+
value: function clearSelection() {
|
|
510
|
+
if (this.target) {
|
|
511
|
+
this.target.blur();
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
window.getSelection().removeAllRanges();
|
|
515
|
+
}
|
|
516
|
+
}, {
|
|
517
|
+
key: 'destroy',
|
|
518
|
+
value: function destroy() {
|
|
519
|
+
this.removeFake();
|
|
520
|
+
}
|
|
521
|
+
}, {
|
|
522
|
+
key: 'action',
|
|
523
|
+
set: function set() {
|
|
524
|
+
var action = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'copy';
|
|
525
|
+
|
|
526
|
+
this._action = action;
|
|
527
|
+
|
|
528
|
+
if (this._action !== 'copy' && this._action !== 'cut') {
|
|
529
|
+
throw new Error('Invalid "action" value, use either "copy" or "cut"');
|
|
530
|
+
}
|
|
531
|
+
},
|
|
532
|
+
get: function get() {
|
|
533
|
+
return this._action;
|
|
534
|
+
}
|
|
535
|
+
}, {
|
|
536
|
+
key: 'target',
|
|
537
|
+
set: function set(target) {
|
|
538
|
+
if (target !== undefined) {
|
|
539
|
+
if (target && (typeof target === 'undefined' ? 'undefined' : _typeof(target)) === 'object' && target.nodeType === 1) {
|
|
540
|
+
if (this.action === 'copy' && target.hasAttribute('disabled')) {
|
|
541
|
+
throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');
|
|
542
|
+
}
|
|
543
|
+
|
|
544
|
+
if (this.action === 'cut' && (target.hasAttribute('readonly') || target.hasAttribute('disabled'))) {
|
|
545
|
+
throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
this._target = target;
|
|
549
|
+
} else {
|
|
550
|
+
throw new Error('Invalid "target" value, use a valid Element');
|
|
551
|
+
}
|
|
552
|
+
}
|
|
553
|
+
},
|
|
554
|
+
get: function get() {
|
|
555
|
+
return this._target;
|
|
556
|
+
}
|
|
557
|
+
}]);
|
|
558
|
+
|
|
559
|
+
return ClipboardAction;
|
|
560
|
+
}();
|
|
561
|
+
|
|
562
|
+
module.exports = ClipboardAction;
|
|
563
|
+
});
|
|
564
|
+
|
|
565
|
+
},{"select":5}],8:[function(require,module,exports){
|
|
566
|
+
(function (global, factory) {
|
|
567
|
+
if (typeof define === "function" && define.amd) {
|
|
568
|
+
define(['module', './clipboard-action', 'tiny-emitter', 'good-listener'], factory);
|
|
569
|
+
} else if (typeof exports !== "undefined") {
|
|
570
|
+
factory(module, require('./clipboard-action'), require('tiny-emitter'), require('good-listener'));
|
|
571
|
+
} else {
|
|
572
|
+
var mod = {
|
|
573
|
+
exports: {}
|
|
574
|
+
};
|
|
575
|
+
factory(mod, global.clipboardAction, global.tinyEmitter, global.goodListener);
|
|
576
|
+
global.clipboard = mod.exports;
|
|
577
|
+
}
|
|
578
|
+
})(this, function (module, _clipboardAction, _tinyEmitter, _goodListener) {
|
|
579
|
+
'use strict';
|
|
580
|
+
|
|
581
|
+
var _clipboardAction2 = _interopRequireDefault(_clipboardAction);
|
|
582
|
+
|
|
583
|
+
var _tinyEmitter2 = _interopRequireDefault(_tinyEmitter);
|
|
584
|
+
|
|
585
|
+
var _goodListener2 = _interopRequireDefault(_goodListener);
|
|
586
|
+
|
|
587
|
+
function _interopRequireDefault(obj) {
|
|
588
|
+
return obj && obj.__esModule ? obj : {
|
|
589
|
+
default: obj
|
|
590
|
+
};
|
|
591
|
+
}
|
|
592
|
+
|
|
593
|
+
function _classCallCheck(instance, Constructor) {
|
|
594
|
+
if (!(instance instanceof Constructor)) {
|
|
595
|
+
throw new TypeError("Cannot call a class as a function");
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
var _createClass = function () {
|
|
600
|
+
function defineProperties(target, props) {
|
|
601
|
+
for (var i = 0; i < props.length; i++) {
|
|
602
|
+
var descriptor = props[i];
|
|
603
|
+
descriptor.enumerable = descriptor.enumerable || false;
|
|
604
|
+
descriptor.configurable = true;
|
|
605
|
+
if ("value" in descriptor) descriptor.writable = true;
|
|
606
|
+
Object.defineProperty(target, descriptor.key, descriptor);
|
|
607
|
+
}
|
|
608
|
+
}
|
|
609
|
+
|
|
610
|
+
return function (Constructor, protoProps, staticProps) {
|
|
611
|
+
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
|
612
|
+
if (staticProps) defineProperties(Constructor, staticProps);
|
|
613
|
+
return Constructor;
|
|
614
|
+
};
|
|
615
|
+
}();
|
|
616
|
+
|
|
617
|
+
function _possibleConstructorReturn(self, call) {
|
|
618
|
+
if (!self) {
|
|
619
|
+
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
|
623
|
+
}
|
|
624
|
+
|
|
625
|
+
function _inherits(subClass, superClass) {
|
|
626
|
+
if (typeof superClass !== "function" && superClass !== null) {
|
|
627
|
+
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
|
631
|
+
constructor: {
|
|
632
|
+
value: subClass,
|
|
633
|
+
enumerable: false,
|
|
634
|
+
writable: true,
|
|
635
|
+
configurable: true
|
|
636
|
+
}
|
|
637
|
+
});
|
|
638
|
+
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
var Clipboard = function (_Emitter) {
|
|
642
|
+
_inherits(Clipboard, _Emitter);
|
|
643
|
+
|
|
644
|
+
/**
|
|
645
|
+
* @param {String|HTMLElement|HTMLCollection|NodeList} trigger
|
|
646
|
+
* @param {Object} options
|
|
647
|
+
*/
|
|
648
|
+
function Clipboard(trigger, options) {
|
|
649
|
+
_classCallCheck(this, Clipboard);
|
|
650
|
+
|
|
651
|
+
var _this = _possibleConstructorReturn(this, (Clipboard.__proto__ || Object.getPrototypeOf(Clipboard)).call(this));
|
|
652
|
+
|
|
653
|
+
_this.resolveOptions(options);
|
|
654
|
+
_this.listenClick(trigger);
|
|
655
|
+
return _this;
|
|
656
|
+
}
|
|
657
|
+
|
|
658
|
+
/**
|
|
659
|
+
* Defines if attributes would be resolved using internal setter functions
|
|
660
|
+
* or custom functions that were passed in the constructor.
|
|
661
|
+
* @param {Object} options
|
|
662
|
+
*/
|
|
663
|
+
|
|
664
|
+
|
|
665
|
+
_createClass(Clipboard, [{
|
|
666
|
+
key: 'resolveOptions',
|
|
667
|
+
value: function resolveOptions() {
|
|
668
|
+
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
669
|
+
|
|
670
|
+
this.action = typeof options.action === 'function' ? options.action : this.defaultAction;
|
|
671
|
+
this.target = typeof options.target === 'function' ? options.target : this.defaultTarget;
|
|
672
|
+
this.text = typeof options.text === 'function' ? options.text : this.defaultText;
|
|
673
|
+
}
|
|
674
|
+
}, {
|
|
675
|
+
key: 'listenClick',
|
|
676
|
+
value: function listenClick(trigger) {
|
|
677
|
+
var _this2 = this;
|
|
678
|
+
|
|
679
|
+
this.listener = (0, _goodListener2.default)(trigger, 'click', function (e) {
|
|
680
|
+
return _this2.onClick(e);
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
}, {
|
|
684
|
+
key: 'onClick',
|
|
685
|
+
value: function onClick(e) {
|
|
686
|
+
var trigger = e.delegateTarget || e.currentTarget;
|
|
687
|
+
|
|
688
|
+
if (this.clipboardAction) {
|
|
689
|
+
this.clipboardAction = null;
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
this.clipboardAction = new _clipboardAction2.default({
|
|
693
|
+
action: this.action(trigger),
|
|
694
|
+
target: this.target(trigger),
|
|
695
|
+
text: this.text(trigger),
|
|
696
|
+
trigger: trigger,
|
|
697
|
+
emitter: this
|
|
698
|
+
});
|
|
699
|
+
}
|
|
700
|
+
}, {
|
|
701
|
+
key: 'defaultAction',
|
|
702
|
+
value: function defaultAction(trigger) {
|
|
703
|
+
return getAttributeValue('action', trigger);
|
|
704
|
+
}
|
|
705
|
+
}, {
|
|
706
|
+
key: 'defaultTarget',
|
|
707
|
+
value: function defaultTarget(trigger) {
|
|
708
|
+
var selector = getAttributeValue('target', trigger);
|
|
709
|
+
|
|
710
|
+
if (selector) {
|
|
711
|
+
return document.querySelector(selector);
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
}, {
|
|
715
|
+
key: 'defaultText',
|
|
716
|
+
value: function defaultText(trigger) {
|
|
717
|
+
return getAttributeValue('text', trigger);
|
|
718
|
+
}
|
|
719
|
+
}, {
|
|
720
|
+
key: 'destroy',
|
|
721
|
+
value: function destroy() {
|
|
722
|
+
this.listener.destroy();
|
|
723
|
+
|
|
724
|
+
if (this.clipboardAction) {
|
|
725
|
+
this.clipboardAction.destroy();
|
|
726
|
+
this.clipboardAction = null;
|
|
727
|
+
}
|
|
728
|
+
}
|
|
729
|
+
}]);
|
|
730
|
+
|
|
731
|
+
return Clipboard;
|
|
732
|
+
}(_tinyEmitter2.default);
|
|
733
|
+
|
|
734
|
+
/**
|
|
735
|
+
* Helper function to retrieve attribute value.
|
|
736
|
+
* @param {String} suffix
|
|
737
|
+
* @param {Element} element
|
|
738
|
+
*/
|
|
739
|
+
function getAttributeValue(suffix, element) {
|
|
740
|
+
var attribute = 'data-clipboard-' + suffix;
|
|
741
|
+
|
|
742
|
+
if (!element.hasAttribute(attribute)) {
|
|
743
|
+
return;
|
|
744
|
+
}
|
|
745
|
+
|
|
746
|
+
return element.getAttribute(attribute);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
module.exports = Clipboard;
|
|
750
|
+
});
|
|
751
|
+
|
|
752
|
+
},{"./clipboard-action":7,"good-listener":4,"tiny-emitter":6}]},{},[8])(8)
|
|
753
|
+
});
|