@loopmode/set-clipboard-data
TypeScript icon, indicating that this package has built-in type declarations

1.0.2 • Public • Published

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 } = {})

Dependencies (0)

    Dev Dependencies (2)

    Package Sidebar

    Install

    npm i @loopmode/set-clipboard-data

    Weekly Downloads

    1

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    4.88 kB

    Total Files

    7

    Last publish

    Collaborators

    • loopmode