2021-02-13 19:55:45 +01:00
|
|
|
import {Component, Vue} from 'nuxt-property-decorator'
|
|
|
|
|
2021-02-06 11:14:28 +01:00
|
|
|
const copyToClipboard = (text: string) => {
|
|
|
|
const input = document.createElement('textarea')
|
|
|
|
input.innerHTML = text
|
|
|
|
document.body.appendChild(input)
|
|
|
|
input.select()
|
|
|
|
const result = document.execCommand('copy')
|
|
|
|
document.body.removeChild(input)
|
|
|
|
return result
|
|
|
|
}
|
|
|
|
|
2021-02-13 19:55:45 +01:00
|
|
|
@Component
|
2021-03-14 20:11:39 +01:00
|
|
|
export class CopyableMixin extends Vue {
|
2021-02-13 19:55:45 +01:00
|
|
|
copy(text: string, toastText = 'Copied to clipboard !') {
|
|
|
|
copyToClipboard(text)
|
|
|
|
console.log(toastText)
|
|
|
|
this.$toast.success(toastText)
|
2021-02-06 11:14:28 +01:00
|
|
|
}
|
|
|
|
}
|