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.
 
 
 

22 lines
497 B

import Clipboard from 'clipboard'
export function handleClipboard (text, event, onSuccess, onError) {
event = event || {}
const clipboard = new Clipboard(event.target, {
text: () => text
})
clipboard.on('success', () => {
onSuccess()
clipboard.off('error')
clipboard.off('success')
clipboard.destroy()
})
clipboard.on('error', () => {
onError()
clipboard.off('error')
clipboard.off('success')
clipboard.destroy()
})
clipboard.onClick(event)
}