UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

42 lines (41 loc) 1.54 kB
import type { CleanupFunction } from '../__internal__/types.js'; type GetClipboardOptions<AllowRead extends boolean> = { /** * Whether to automatically clean up the event listeners or not. * @note If set to `true`, you must call `getClipboardText` in the component initialization lifecycle. * @default true */ autoCleanup?: boolean; /** * Whether to allow reading from the clipboard. * @default false */ allowRead?: AllowRead; /** * How long before {@link GetClipboardReturn.isCopied | `GetClipboardReturn.isCopied`} is set to `false`. * @default 2000 */ copyDuration?: number; /** * Whether to fallback to the legacy `document.execCommand('copy')` for copying if the Clipboard API is not supported or not. * @default false */ legacyCopy?: boolean; }; type GetClipboardReturn = { readonly isSupported: boolean; readonly isCopied: boolean; /** The text currently in the clipboard. */ readonly text: string; /** Copies text to the clipboard. */ copyText: (value: string) => void; /** Cleans up the event listeners. */ cleanup: CleanupFunction; }; /** * Provides write (and optionally read) access to the text clipboard. * @param options Additional options to customize the behavior. * @see https://svelte-librarian.github.io/sv-use/docs/core/get-clipboard-text */ export declare function getClipboardText<AllowRead extends boolean = false>(options?: GetClipboardOptions<AllowRead>): GetClipboardReturn; export {};