# clipboard

{% hint style="info" %}
Tip: It is recommended to use Clipboard Viewer ([Win](https://freeclipboardviewer.com/) / [Mac](https://langui.net/clipboard-viewer/)) tool for development debugging to make the development process smoother.
{% endhint %}

```javascript
await eagle.clipboard.writeText('Example string');

console.log(await eagle.clipboard.readText());
```

***

### Methods <a href="#z1a5y" id="z1a5y"></a>

## clear() <a href="#tkp0d" id="tkp0d"></a>

Clear the clipboard content.

```javascript
eagle.clipboard.writeText('Example string');
eagle.clipboard.clear();
console.log(eagle.clipboard.readText());	// undefined
```

***

## has(format) <a href="#p4ult" id="p4ult"></a>

Check if the current clipboard content contains the specified format.

* `format` string - Specified format
* Returns boolean - Whether it contains the specified format

```javascript
console.log(eagle.clipboard.has('public/utf8-plain-text'));	// false

const buffer = Buffer.from('writeBuffer', 'utf8');
eagle.clipboard.writeBuffer('public/utf8-plain-text', buffer);

console.log(eagle.clipboard.has('public/utf8-plain-text'));	// true
```

***

## writeText(text) <a href="#eear5" id="eear5"></a>

Write `text` as plain text to the clipboard.

* `text` string - Text to be written

```javascript
eagle.clipboard.writeText('Example string');
console.log(eagle.clipboard.readText());	// 'Example string'
```

***

## readText() <a href="#ytddd" id="ytddd"></a>

Get the plain text content of the current clipboard.

* Returns string

```javascript
console.log(await eagle.clipboard.readText());
```

***

## writeBuffer(format, buffer) <a href="#ol666" id="ol666"></a>

Write `buffer` as `format` type to the clipboard.

* `format` string - Clipboard format
* `buffer` Buffer - Buffer format of the content to be written

```javascript
const buffer = Buffer.from('writeBuffer', 'utf8');
eagle.clipboard.writeBuffer('public/utf8-plain-text', buffer);
```

***

## readBuffer(format) <a href="#gadle" id="gadle"></a>

Read `format` type content from the clipboard.

* Returns Buffer

```javascript
const buffer = Buffer.from('this is binary', 'utf8');
eagle.clipboard.writeBuffer('public/utf8-plain-text', buffer);

const out = eagle.clipboard.readBuffer('public/utf8-plain-text');

console.log(buffer.equals(out));	// true
```

***

## writeImage(image) <a href="#cwuzf" id="cwuzf"></a>

Write `image` to the clipboard.

* `image` [NativeImage](https://www.electronjs.org/docs/latest/api/native-image) - Image to be written to the clipboard

```javascript
let img = nativeImage.createFromPath('path_to_img_file');
eagle.clipboard.writeImage(img);
```

***

## readImage() <a href="#hfggy" id="hfggy"></a>

Read image format content from the clipboard.

* Returns [NativeImage](https://www.electronjs.org/docs/latest/api/native-image)

```javascript
let input = nativeImage.createFromPath('path_to_img_file');
eagle.clipboard.writeImage(input);

let output = eagle.clipboard.readImage();
```

***

## writeHTML(markup) <a href="#naujl" id="naujl"></a>

Write `markup` as HTML format to the clipboard.

* `markup` string

```javascript
eagle.clipboard.writeHTML('<b>Hi</b>');
console.log(eagle.clipboard.readHTML());	// <b>Hi</b>
```

***

## readHTML() <a href="#btaqx" id="btaqx"></a>

Read HTML format content from the clipboard.

* Returns string

```javascript
eagle.clipboard.writeHTML('<b>Hi</b>');
console.log(eagle.clipboard.readHTML());	// <b>Hi</b>
```

***

## copyFiles(paths) <a href="#t8sny" id="t8sny"></a>

Copy the specified files to the clipboard, supporting paste in file manager.

* `paths` strings\[] - Files to be copied to the clipboard.

```javascript
eagle.clipboard.copyFiles([
    'path_to_file',
    'path_to_file2'
]);
```

***


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://developer.eagle.cool/plugin-api/api/clipboard.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
