You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
hezhiying/node_modules/vue-clipboard2/dist/vue-clipboard.js

111 lines
14 KiB

1 year ago
(function(){function r(e,n,t){function o(i,f){if(!n[i]){if(!e[i]){var c="function"==typeof require&&require;if(!f&&c)return c(i,!0);if(u)return u(i,!0);var a=new Error("Cannot find module '"+i+"'");throw a.code="MODULE_NOT_FOUND",a}var p=n[i]={exports:{}};e[i][0].call(p.exports,function(r){var n=e[i][1][r];return o(n||r)},p,p.exports,r,e,n,t)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i<t.length;i++)o(t[i]);return o}return r})()({1:[function(require,module,exports){
(function (global){(function (){
var VueClipboard = require('./vue-clipboard.js')
global.VueClipboard = VueClipboard
window.Vue && window.Vue.use && window.Vue.use(VueClipboard)
}).call(this)}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./vue-clipboard.js":3}],2:[function(require,module,exports){
/*!
* clipboard.js v2.0.8
* https://clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
*/
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.ClipboardJS=e():t.ClipboardJS=e()}(this,function(){return n={134:function(t,e,n){"use strict";n.d(e,{default:function(){return r}});var e=n(279),i=n.n(e),e=n(370),a=n.n(e),e=n(817),o=n.n(e);function c(t){return(c="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(t)}function u(t,e){for(var n=0;n<e.length;n++){var r=e[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(t,r.key,r)}}var l=function(){function e(t){!function(t){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this),this.resolveOptions(t),this.initSelection()}var t,n,r;return t=e,(n=[{key:"resolveOptions",value:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:{};this.action=t.action,this.container=t.container,this.emitter=t.emitter,this.target=t.target,this.text=t.text,this.trigger=t.trigger,this.selectedText=""}},{key:"initSelection",value:function(){this.text?this.selectFake():this.target&&this.selectTarget()}},{key:"createFakeElement",value:function(){var t="rtl"===document.documentElement.getAttribute("dir");this.fakeElem=document.createElement("textarea"),this.fakeElem.style.fontSize="12pt",this.fakeElem.style.border="0",this.fakeElem.style.padding="0",this.fakeElem.style.margin="0",this.fakeElem.style.position="absolute",this.fakeElem.style[t?"right":"left"]="-9999px";t=window.pageYOffset||document.documentElement.scrollTop;return this.fakeElem.style.top="".concat(t,"px"),this.fakeElem.setAttribute("readonly",""),this.fakeElem.value=this.text,this.fakeElem}},{key:"selectFake",value:function(){var t=this,e=this.createFakeElement();this.fakeHandlerCallback=function(){return t.removeFake()},this.fakeHandler=this.container.addEventListener("click",this.fakeHandlerCallback)||!0,this.container.appendChild(e),this.selectedText=o()(e),this.copyText(),this.removeFake()}},{key:"removeFake",value:function(){this.fakeHandler&&(this.container.removeEventListener("click",this.fakeHandlerCallback),this.fakeHandler=null,this.fakeHandlerCallback=null),this.fakeElem&&(this.container.removeChild(this.fakeElem),this.fakeElem=null)}},{key:"selectTarget",value:function(){this.selectedText=o()(this.target),this.copyText()}},{key:"copyText",value:function(){var e;try{e=document.execCommand(this.action)}catch(t){e=!1}this.handleResult(e)}},{key:"handleResult",value:function(t){this.emitter.emit(t?"success":"error",{action:this.action,text:this.selectedText,trigger:this.trigger,clearSelection:this.clearSelection.bind(this)})}},{key:"clearSelection",value:function(){this.trigger&&this.trigger.focus(),document.activeElement.blur(),window.getSelection().removeAllRanges()}},{key:"destroy",value:function(){this.removeFake()}},{key:"action",set:function(){var t=0<arguments.length&&void 0!==arguments[0]?arguments[0]:"copy";if(this._action=t,"copy"!==this._action&&"cut"!==this._action)throw new Error('Invalid "action" value, use either "copy" or "cut"')},get:function(){return this._action}},{key:"target",set:function(t){if(void 0!==t){if(!t||"object"!==c(t)||1!==t.nodeType)throw new Error('Invalid "target" value, use a valid Element');if("copy"===this.action&&t.hasAttribute("disabled"))throw new Error('Invalid "target" attribute. Please use "readonly" instead of "disabled" attribute');if("cut"===this.action&&(t.hasAttribute("readonly")||t.hasAttribute("disabled")))throw new Error('Invalid "target" attribute. You can\'t cut text from elements with "readonly" or "disabled" attributes');this._target=t}},get:function(){return this._target}}])&&u(t.prototype,n),r&&u(t,r),e}();function s(t){return(s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototyp
},{}],3:[function(require,module,exports){
var Clipboard = require('clipboard/dist/clipboard.min.js') // FIXME: workaround for browserify
var VueClipboardConfig = {
autoSetContainer: false,
appendToBody: true // This fixes IE, see #50
}
var VueClipboard = {
install: function (Vue) {
var globalPrototype = Vue.version.slice(0, 2) === '3.' ? Vue.config.globalProperties : Vue.prototype
globalPrototype.$clipboardConfig = VueClipboardConfig
globalPrototype.$copyText = function (text, container) {
return new Promise(function (resolve, reject) {
var fakeElement = document.createElement('button')
var clipboard = new Clipboard(fakeElement, {
text: function () { return text },
action: function () { return 'copy' },
container: typeof container === 'object' ? container : document.body
})
clipboard.on('success', function (e) {
clipboard.destroy()
resolve(e)
})
clipboard.on('error', function (e) {
clipboard.destroy()
reject(e)
})
if (VueClipboardConfig.appendToBody) document.body.appendChild(fakeElement)
fakeElement.click()
if (VueClipboardConfig.appendToBody) document.body.removeChild(fakeElement)
})
}
Vue.directive('clipboard', {
bind: function (el, binding, vnode) {
if (binding.arg === 'success') {
el._vClipboard_success = binding.value
} else if (binding.arg === 'error') {
el._vClipboard_error = binding.value
} else {
var clipboard = new Clipboard(el, {
text: function () { return binding.value },
action: function () { return binding.arg === 'cut' ? 'cut' : 'copy' },
container: VueClipboardConfig.autoSetContainer ? el : undefined
})
clipboard.on('success', function (e) {
var callback = el._vClipboard_success
callback && callback(e)
})
clipboard.on('error', function (e) {
var callback = el._vClipboard_error
callback && callback(e)
})
el._vClipboard = clipboard
}
},
update: function (el, binding) {
if (binding.arg === 'success') {
el._vClipboard_success = binding.value
} else if (binding.arg === 'error') {
el._vClipboard_error = binding.value
} else {
el._vClipboard.text = function () { return binding.value }
el._vClipboard.action = function () { return binding.arg === 'cut' ? 'cut' : 'copy' }
}
},
unbind: function (el, binding) {
// FIXME: investigate why $element._vClipboard was missing
if (!el._vClipboard) return
if (binding.arg === 'success') {
delete el._vClipboard_success
} else if (binding.arg === 'error') {
delete el._vClipboard_error
} else {
el._vClipboard.destroy()
delete el._vClipboard
}
}
})
},
config: VueClipboardConfig
}
if (typeof exports === 'object') {
module.exports = VueClipboard
} else if (typeof define === 'function' && define.amd) {
define([], function () {
return VueClipboard
})
}
},{"clipboard/dist/clipboard.min.js":2}]},{},[1]);