1.0.2 • Published 3 years ago

@loopmode/set-clipboard-data v1.0.2

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

set-clipboard-data

Sets data to the clipboard via document.execComand("copy") and returns a promise.

The promise is resolved when the data has been set to the clipboard. This is detected via document.addEventListener("copy"). It is rejected if the clipboard does not contain the specified value after the copy event, or if the event is not fired after a specific time (rejectTimeout option)

Usage

import setClipboardData from '@loopmode/set-clipboard-data';

async function handleCopyClick() {
    const clipboardValue = await setClipboardData(this.state.currentValue);
    console.log('done!', clipboardValue);
}

Options

Signature:

setClipboardData(data = '', { mime = 'text/plain', timeout = 60000 } = {})
1.0.2

3 years ago

1.0.0

6 years ago