mirror of
https://github.com/zenorocha/clipboard.js.git
synced 2023-08-10 21:12:48 +03:00
Compare commits
9 Commits
v2.0.10
...
isolate/ac
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d1eac52d40 | ||
|
|
b43d93e69d | ||
|
|
ef32d876de | ||
|
|
e7e38a18e0 | ||
|
|
455b7fdb0c | ||
|
|
a8c35683a6 | ||
|
|
f267fb88f2 | ||
|
|
f99af48fd1 | ||
|
|
b0aa1dfaca |
26
.github/workflows/test.js.yml
vendored
26
.github/workflows/test.js.yml
vendored
@@ -5,12 +5,9 @@ name: build
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
branches: [ master ]
|
||||
pull_request:
|
||||
branches: [master]
|
||||
|
||||
env:
|
||||
FORCE_COLOR: 2
|
||||
branches: [ master ]
|
||||
|
||||
jobs:
|
||||
build:
|
||||
@@ -23,12 +20,13 @@ jobs:
|
||||
# For now is not possible to target LTS verssions =/ check progress here https://github.com/actions/setup-node/issues/26
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v2
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm run lint
|
||||
- run: npm test
|
||||
- uses: actions/checkout@v2
|
||||
- name: Use Node.js ${{ matrix.node-version }}
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: ${{ matrix.node-version }}
|
||||
- run: npm ci
|
||||
- run: npm run build --if-present
|
||||
- run: npm run lint
|
||||
- run: npm test
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clipboard",
|
||||
"version": "2.0.10",
|
||||
"version": "2.0.8",
|
||||
"description": "Modern copy to clipboard. No Flash. Just 3kb",
|
||||
"license": "MIT",
|
||||
"main": "dist/clipboard.js",
|
||||
|
||||
@@ -20,15 +20,11 @@
|
||||
var clipboard = new ClipboardJS(btn);
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -20,15 +20,11 @@
|
||||
var clipboard = new ClipboardJS(btns);
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -19,15 +19,11 @@
|
||||
var clipboard = new ClipboardJS('.btn');
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -22,15 +22,11 @@
|
||||
});
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -21,15 +21,11 @@
|
||||
});
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -24,15 +24,11 @@
|
||||
var clipboard = new ClipboardJS('.btn');
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
@@ -24,9 +24,7 @@
|
||||
var clipboard = new ClipboardJS('.btn');
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
|
||||
@@ -24,15 +24,11 @@
|
||||
var clipboard = new ClipboardJS('.btn');
|
||||
|
||||
clipboard.on('success', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
|
||||
clipboard.on('error', function (e) {
|
||||
console.info('Action:', e.action);
|
||||
console.info('Text:', e.text);
|
||||
console.info('Trigger:', e.trigger);
|
||||
console.log(e);
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
|
||||
54
dist/clipboard.js
vendored
54
dist/clipboard.js
vendored
@@ -1,5 +1,5 @@
|
||||
/*!
|
||||
* clipboard.js v2.0.10
|
||||
* clipboard.js v2.0.8
|
||||
* https://clipboardjs.com/
|
||||
*
|
||||
* Licensed MIT © Zeno Rocha
|
||||
@@ -17,7 +17,7 @@
|
||||
return /******/ (function() { // webpackBootstrap
|
||||
/******/ var __webpack_modules__ = ({
|
||||
|
||||
/***/ 686:
|
||||
/***/ 747:
|
||||
/***/ (function(__unused_webpack_module, __webpack_exports__, __webpack_require__) {
|
||||
|
||||
"use strict";
|
||||
@@ -49,12 +49,12 @@ function command(type) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
;// CONCATENATED MODULE: ./src/actions/cut.js
|
||||
;// CONCATENATED MODULE: ./src/clipboard-action-cut.js
|
||||
|
||||
|
||||
/**
|
||||
* Cut action wrapper.
|
||||
* @param {String|HTMLElement} target
|
||||
* @param {HTMLElement} target
|
||||
* @return {String}
|
||||
*/
|
||||
|
||||
@@ -64,7 +64,7 @@ var ClipboardActionCut = function ClipboardActionCut(target) {
|
||||
return selectedText;
|
||||
};
|
||||
|
||||
/* harmony default export */ var actions_cut = (ClipboardActionCut);
|
||||
/* harmony default export */ var clipboard_action_cut = (ClipboardActionCut);
|
||||
;// CONCATENATED MODULE: ./src/common/create-fake-element.js
|
||||
/**
|
||||
* Creates a fake textarea element with a value.
|
||||
@@ -90,7 +90,7 @@ function createFakeElement(value) {
|
||||
fakeElement.value = value;
|
||||
return fakeElement;
|
||||
}
|
||||
;// CONCATENATED MODULE: ./src/actions/copy.js
|
||||
;// CONCATENATED MODULE: ./src/clipboard-action-copy.js
|
||||
|
||||
|
||||
|
||||
@@ -121,8 +121,8 @@ var ClipboardActionCopy = function ClipboardActionCopy(target) {
|
||||
return selectedText;
|
||||
};
|
||||
|
||||
/* harmony default export */ var actions_copy = (ClipboardActionCopy);
|
||||
;// CONCATENATED MODULE: ./src/actions/default.js
|
||||
/* harmony default export */ var clipboard_action_copy = (ClipboardActionCopy);
|
||||
;// CONCATENATED MODULE: ./src/clipboard-action-default.js
|
||||
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); }
|
||||
|
||||
|
||||
@@ -163,20 +163,20 @@ var ClipboardActionDefault = function ClipboardActionDefault() {
|
||||
|
||||
|
||||
if (text) {
|
||||
return actions_copy(text, {
|
||||
return clipboard_action_copy(text, {
|
||||
container: container
|
||||
});
|
||||
} // Defines which selection strategy based on `target` property.
|
||||
|
||||
|
||||
if (target) {
|
||||
return action === 'cut' ? actions_cut(target) : actions_copy(target, {
|
||||
return action === 'cut' ? clipboard_action_cut(target) : clipboard_action_copy(target, {
|
||||
container: container
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
/* harmony default export */ var actions_default = (ClipboardActionDefault);
|
||||
/* harmony default export */ var clipboard_action_default = (ClipboardActionDefault);
|
||||
;// CONCATENATED MODULE: ./src/clipboard.js
|
||||
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); }
|
||||
|
||||
@@ -241,6 +241,8 @@ var Clipboard = /*#__PURE__*/function (_Emitter) {
|
||||
_classCallCheck(this, Clipboard);
|
||||
|
||||
_this = _super.call(this);
|
||||
_this.ClipboardActionCut = clipboard_action_cut.bind(_assertThisInitialized(_this));
|
||||
_this.ClipboardActionCopy = clipboard_action_copy.bind(_assertThisInitialized(_this));
|
||||
|
||||
_this.resolveOptions(options);
|
||||
|
||||
@@ -287,17 +289,16 @@ var Clipboard = /*#__PURE__*/function (_Emitter) {
|
||||
key: "onClick",
|
||||
value: function onClick(e) {
|
||||
var trigger = e.delegateTarget || e.currentTarget;
|
||||
var action = this.action(trigger) || 'copy';
|
||||
var text = actions_default({
|
||||
action: action,
|
||||
var selectedText = clipboard_action_default({
|
||||
action: this.action(trigger),
|
||||
container: this.container,
|
||||
target: this.target(trigger),
|
||||
text: this.text(trigger)
|
||||
}); // Fires an event based on the copy operation result.
|
||||
|
||||
this.emit(text ? 'success' : 'error', {
|
||||
action: action,
|
||||
text: text,
|
||||
this.emit(selectedText ? 'success' : 'error', {
|
||||
action: this.action,
|
||||
text: selectedText,
|
||||
trigger: trigger,
|
||||
clearSelection: function clearSelection() {
|
||||
if (trigger) {
|
||||
@@ -333,13 +334,6 @@ var Clipboard = /*#__PURE__*/function (_Emitter) {
|
||||
return document.querySelector(selector);
|
||||
}
|
||||
}
|
||||
/**
|
||||
* Allow fire programmatically a copy action
|
||||
* @param {String|HTMLElement} target
|
||||
* @param {Object} options
|
||||
* @returns Text copied.
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "defaultText",
|
||||
|
||||
@@ -365,18 +359,12 @@ var Clipboard = /*#__PURE__*/function (_Emitter) {
|
||||
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
|
||||
container: document.body
|
||||
};
|
||||
return actions_copy(target, options);
|
||||
return clipboard_action_copy(target, options);
|
||||
}
|
||||
/**
|
||||
* Allow fire programmatically a cut action
|
||||
* @param {String|HTMLElement} target
|
||||
* @returns Text cutted.
|
||||
*/
|
||||
|
||||
}, {
|
||||
key: "cut",
|
||||
value: function cut(target) {
|
||||
return actions_cut(target);
|
||||
return clipboard_action_cut(target);
|
||||
}
|
||||
/**
|
||||
* Returns the support of the given action, or all actions if no action is
|
||||
@@ -870,7 +858,7 @@ module.exports.TinyEmitter = E;
|
||||
/******/ // module exports must be returned from runtime so entry inlining is disabled
|
||||
/******/ // startup
|
||||
/******/ // Load entry module and return exports
|
||||
/******/ return __webpack_require__(686);
|
||||
/******/ return __webpack_require__(747);
|
||||
/******/ })()
|
||||
.default;
|
||||
});
|
||||
4
dist/clipboard.min.js
vendored
4
dist/clipboard.min.js
vendored
File diff suppressed because one or more lines are too long
11667
package-lock.json
generated
11667
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -3,7 +3,7 @@
|
||||
Package.describe({
|
||||
name: 'zenorocha:clipboard',
|
||||
summary: 'Modern copy to clipboard. No Flash. Just 3kb.',
|
||||
version: '2.0.10',
|
||||
version: '2.0.8',
|
||||
git: 'https://github.com/zenorocha/clipboard.js',
|
||||
});
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "clipboard",
|
||||
"version": "2.0.10",
|
||||
"version": "2.0.8",
|
||||
"description": "Modern copy to clipboard. No Flash. Just 2kb",
|
||||
"homepage": "https://clipboardjs.com",
|
||||
"repository": "zenorocha/clipboard.js",
|
||||
|
||||
@@ -69,18 +69,17 @@ class Clipboard extends Emitter {
|
||||
*/
|
||||
onClick(e) {
|
||||
const trigger = e.delegateTarget || e.currentTarget;
|
||||
const action = this.action(trigger) || 'copy';
|
||||
const text = ClipboardActionDefault({
|
||||
action,
|
||||
const selectedText = ClipboardActionDefault({
|
||||
action: this.action(trigger),
|
||||
container: this.container,
|
||||
target: this.target(trigger),
|
||||
text: this.text(trigger),
|
||||
});
|
||||
|
||||
// Fires an event based on the copy operation result.
|
||||
this.emit(text ? 'success' : 'error', {
|
||||
action,
|
||||
text,
|
||||
this.emit(selectedText ? 'success' : 'error', {
|
||||
action: this.action,
|
||||
text: selectedText,
|
||||
trigger,
|
||||
clearSelection() {
|
||||
if (trigger) {
|
||||
|
||||
@@ -158,7 +158,6 @@ describe('Clipboard', () => {
|
||||
|
||||
clipboard.on('success', (e) => {
|
||||
assert.property(e, 'action');
|
||||
assert.equal(e.action, 'copy');
|
||||
assert.property(e, 'text');
|
||||
assert.property(e, 'trigger');
|
||||
assert.property(e, 'clearSelection');
|
||||
|
||||
Reference in New Issue
Block a user