UNPKG

@jupyterlab/apputils

Version:
78 lines (77 loc) 2.33 kB
import { MimeData } from '@lumino/coreutils'; export type ClipboardData = string | MimeData; /** * The clipboard interface. */ export declare namespace Clipboard { /** * Get the application clipboard instance. * * @deprecated To use `SystemClipboard.getInstance` for copy/cut/paste cells. */ 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>; /** * 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; } }