Skip to content

Commit 7343f61

Browse files
committed
first commit
0 parents  commit 7343f61

File tree

5 files changed

+116
-0
lines changed

5 files changed

+116
-0
lines changed

.gitignore

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
# See https://help.github.com/ignore-files/ for more about ignoring files.
3+
4+
# dependencies
5+
node_modules/
6+
7+
# testing
8+
/coverage
9+
10+
# misc
11+
.DS_Store
12+
.env.local
13+
.env.development.local
14+
.env.test.local
15+
.env.production.local
16+
17+
npm-debug.log*
18+
yarn-debug.log*
19+
yarn-error.log*
20+
package-lock.json*
21+
22+
# IDE
23+
/.idea
24+
25+
lib/
26+
es/
27+
dist/
28+
build/
29+
.vscode
30+
31+
# publish
32+
*.tgz

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
vue-copy-to-cliboard
2+
----
3+
4+
Copy to clipboard Vue component

index.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import copy from 'copy-to-clipboard'
2+
3+
export const CopyToClipboardProps = {
4+
text: {
5+
type: String,
6+
required: true
7+
},
8+
options: {
9+
type: Object,
10+
default: () => {}
11+
}
12+
}
13+
14+
const CopyToClipboard = {
15+
name: 'VueCopyToClipboard',
16+
functional: true,
17+
props: CopyToClipboardProps,
18+
render (h, ctx) {
19+
const { props: { text, options = {} }, listeners: { copy: onCopy } } = ctx
20+
21+
const handleClick = (e) => {
22+
// Bypass onClick if it was present
23+
e.preventDefault()
24+
e.stopPropagation()
25+
26+
const result = copy(text, options)
27+
28+
if (onCopy) {
29+
onCopy(text, result)
30+
}
31+
}
32+
33+
return h('span', { on: { click: handleClick }}, ctx.children)
34+
}
35+
}
36+
37+
/* istanbul ignore next */
38+
CopyToClipboard.install = function (Vue) {
39+
Vue.component(CopyToClipboard.name, CopyToClipboard)
40+
}
41+
42+
export default CopyToClipboard

package.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"name": "vue-copy-to-clipboard",
3+
"version": "1.0.0",
4+
"description": "Copy to clipboard Vue component",
5+
"main": "index.js",
6+
"repository": "https://github.com/vueComponent/vue-copy-to-clipboard",
7+
"author": "Sendya <[email protected]>",
8+
"contributors": [
9+
"Sendya <[email protected]>"
10+
],
11+
"license": "MIT",
12+
"files": [
13+
"es",
14+
"lib",
15+
"index.js"
16+
],
17+
"peerDependencies": {
18+
"vue": ">=2.6.0"
19+
},
20+
"dependencies": {
21+
"copy-to-clipboard": "^3.3.1"
22+
}
23+
}

yarn.lock

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
2+
# yarn lockfile v1
3+
4+
5+
copy-to-clipboard@^3.3.1:
6+
version "3.3.1"
7+
resolved "https://registry.npm.taobao.org/copy-to-clipboard/download/copy-to-clipboard-3.3.1.tgz?cache=0&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fcopy-to-clipboard%2Fdownload%2Fcopy-to-clipboard-3.3.1.tgz#115aa1a9998ffab6196f93076ad6da3b913662ae"
8+
integrity sha1-EVqhqZmP+rYZb5MHatbaO5E2Yq4=
9+
dependencies:
10+
toggle-selection "^1.0.6"
11+
12+
toggle-selection@^1.0.6:
13+
version "1.0.6"
14+
resolved "https://registry.npm.taobao.org/toggle-selection/download/toggle-selection-1.0.6.tgz#6e45b1263f2017fa0acc7d89d78b15b8bf77da32"
15+
integrity sha1-bkWxJj8gF/oKzH2J14sVuL932jI=

0 commit comments

Comments
 (0)