Skip to content

Pasteboard

Access the system clipboard

Pasteboard provides read and write access to the system clipboard (pasteboard).

Use Pasteboard to:

Examples

javascript
Pasteboard.copy("Hello World");
let text = Pasteboard.paste();
console.log(text);
javascript
let img = await Photos.fromLibrary();
Pasteboard.copyImage(img);

Methods

copy

Copy text to clipboard

typescript
static copy(string): void
  • string - Text to copy

Example:

javascript
Pasteboard.copy("text")

paste

Read text from clipboard

typescript
static paste(): string | null

Returns: Clipboard text content, or null if empty

Example:

javascript
let text = Pasteboard.paste()

copyString

Copy text to clipboard (alias)

typescript
static copyString(string): void
  • string - Text to copy

Example:

javascript
Pasteboard.copyString("text")

pasteString

Read text from clipboard (alias)

typescript
static pasteString(): string | null

Returns: Clipboard text content, or null if empty

Example:

javascript
let text = Pasteboard.pasteString()

copyImage

Copy image to clipboard

typescript
static copyImage(imageData): void
  • imageData - Image data object with base64 property

Example:

javascript
Pasteboard.copyImage(imageData)

pasteImage

Read image from clipboard

typescript
static pasteImage(): object | null

Returns: Image data with base64, width, and height, or null if no image

Example:

javascript
let img = Pasteboard.pasteImage()