Skip to content

clipboard

Interact with the system clipboard.

Functions

clipboard.read

clipboard.read(format: ClipboardContentType): Promise<string>;

Read the value of the clipboard. When the format is image, it will return the Data URL of the image.

Example

import { _extension } from '@altdot/extension';
const lastCopiedText = await _extension.clipboard.read('text');
console.log(lastCopiedText);

clipboard.write

clipboard.write(format: ClipboardContentType, value: string): Promise<void>;

Write value to the clipboard. If the format is image, the value must be the Data URL of the image.

import { _extension } from '@altdot/extension';
await _extension.clipboard.write('text', 'Hello world');
await _extension.clipboard.write('html', '<p>Hello world</p>');

clipboard.paste

clipboard.paste(value: string): Promise<void>;

Paste the value into the frontmost app.

import { _extension } from '@altdot/extension';
await _extension.clipboard.paste('Hello world');

Types

clipboard.ClipboardContentType

Content type of the clipboard.

type ClipboardContentType = 'html' | 'text' | 'image' | 'rtf';