Compare commits

..

3 Commits

Author SHA1 Message Date
Beto Muniz
ca882fd16f Apply logic only when target is an input element 2022-05-03 13:21:15 -03:00
Beto Muniz
abfb43cdb5 Improve test description. Remove .only 2022-05-03 13:07:29 -03:00
Beto Muniz
c16f99a0ee Support more HTML input types. 2022-05-03 12:26:42 -03:00
9 changed files with 969 additions and 671 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "clipboard",
"version": "2.0.11",
"version": "2.0.10",
"description": "Modern copy to clipboard. No Flash. Just 3kb",
"license": "MIT",
"main": "dist/clipboard.js",

3
dist/clipboard.js vendored
View File

@@ -1,5 +1,5 @@
/*!
* clipboard.js v2.0.11
* clipboard.js v2.0.10
* https://clipboardjs.com/
*
* Licensed MIT © Zeno Rocha
@@ -319,6 +319,7 @@ var Clipboard = /*#__PURE__*/function (_Emitter) {
trigger.focus();
}
document.activeElement.blur();
window.getSelection().removeAllRanges();
}
});

File diff suppressed because one or more lines are too long

1614
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -3,7 +3,7 @@
Package.describe({
name: 'zenorocha:clipboard',
summary: 'Modern copy to clipboard. No Flash. Just 3kb.',
version: '2.0.11',
version: '2.0.10',
git: 'https://github.com/zenorocha/clipboard.js',
});

View File

@@ -1,6 +1,6 @@
{
"name": "clipboard",
"version": "2.0.11",
"version": "2.0.10",
"description": "Modern copy to clipboard. No Flash. Just 2kb",
"homepage": "https://clipboardjs.com",
"repository": "zenorocha/clipboard.js",
@@ -36,7 +36,7 @@
"karma-sinon": "^1.0.4",
"karma-webpack": "^5.0.0-alpha.5",
"lint-staged": "^10.5.3",
"mocha": "^10.1.0",
"mocha": "^8.2.1",
"prettier": "2.2.1",
"sinon": "^9.2.3",
"tsd": "^0.7.2",

2
src/clipboard.d.ts vendored
View File

@@ -39,7 +39,7 @@ declare class ClipboardJS {
/**
* Fires a copy action
*/
static copy(target: string | Element, options?: CopyActionOptions): string;
static copy(target: string | Element, options: CopyActionOptions): string;
/**
* Fires a cut action

View File

@@ -86,6 +86,7 @@ class Clipboard extends Emitter {
if (trigger) {
trigger.focus();
}
document.activeElement.blur();
window.getSelection().removeAllRanges();
},
});

View File

@@ -171,16 +171,16 @@ describe('Clipboard', () => {
});
describe('#clearSelection', () => {
it('should clear text selection without moving focus', (done) => {
it('should remove focus from target and text selection', (done) => {
let clipboard = new Clipboard('.btn');
clipboard.on('success', (e) => {
e.clearSelection();
let selectedElem = document.activeElement;
let selectedText = window.getSelection().toString();
assert.equal(selectedElem, e.trigger);
e.clearSelection();
assert.equal(selectedElem, document.body);
assert.equal(selectedText, '');
done();