UNPKG

@jupyterlab/apputils

Version:
87 lines (86 loc) • 2.75 kB
import { MimeData } from '@lumino/coreutils'; export type ClipboardData = string | MimeData; /** * The clipboard interface. */ export declare namespace Clipboard { /** * Get the application clipboard instance. */ function getInstance(): MimeData; /** * Set the application clipboard instance. * * @deprecated will be removed in a future release. Use `SystemClipboard.getInstance`. */ function setInstance(value: MimeData): void; /** * Copy text to the system clipboard. * * #### Notes * This can only be called in response to a user input event. */ function copyToSystem(clipboardData: ClipboardData): void; /** * Generate a clipboard event on a node. * * @param node - The element on which to generate the event. * * @param type - The type of event to generate. * `'paste'` events cannot be programmatically generated. * * #### Notes * This can only be called in response to a user input event. */ function generateEvent(node: HTMLElement, type?: 'copy' | 'cut'): void; } /** * The clipboard interface supporting the native clipboard API. */ export declare namespace SystemClipboard { /** * Get the system clipboard instance. */ function getInstance(): IClipboard; /** * The interface for the system clipboard. */ interface IClipboard { /** * Whether the clipboard has data for a given mime type. * Returns `false` if the data does not exist. * * @param mime - The mime type to check. */ hasData(mime: string): Promise<boolean>; /** * Retrieve the data for a given mime type. * Returns `null` if the data does not exist. * * @param mime - The mime type to retrieve. */ getData(mime: string): Promise<unknown | null>; /** * Whether the given data matches the last value this application wrote to * the clipboard for this mime type. * * Pass the value just returned by `getData`. Returns `false` once the * current clipboard data differs from what this application last wrote. * * @param mime - The mime type that was retrieved. * @param data - The data returned by `getData`. */ matchesLastWrite(mime: string, data: unknown): boolean; /** * Set the data for a given mime type. * * @param mime - The mime type to set. * @param data - The data to set. */ setData(mime: string, data: unknown): Promise<void>; /** * Clear the clipboard. */ clear(): void; } }