Plugin API
English
搜索
K

clipboard (Clipboard)

Perform copy and paste operations on the system clipboard.
Tip: It is recommended to use Clipboard Viewer (Win / Mac) tool for development debugging to make the development process smoother.
await eagle.clipboard.writeText('Example string');
console.log(await eagle.clipboard.readText());

Methods

clear()

Clear the clipboard content.
eagle.clipboard.writeText('Example string');
eagle.clipboard.clear();
console.log(eagle.clipboard.readText()); // undefined

has(format)

Check if the current clipboard content contains the specified format.
  • format string - Specified format
  • Returns boolean - Whether it contains the specified format
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(clipboard.has('public/utf8-plain-text')); // true

writeText(text)

Write text as plain text to the clipboard.
  • text string - Text to be written
eagle.clipboard.writeText('Example string');
console.log(eagle.clipboard.readText()); // 'Example string'

readText()

Get the plain text content of the current clipboard.
  • Returns string
console.log(await eagle.clipboard.readText());

writeBuffer(format, buffer)

Write buffer as format type to the clipboard.
  • format string - Clipboard format
  • buffer Buffer - Buffer format of the content to be written
const buffer = Buffer.from('writeBuffer', 'utf8');
eagle.clipboard.writeBuffer('public/utf8-plain-text', buffer);

readBuffer(format)

Read format type content from the clipboard.
  • Returns Buffer
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)

Write image to the clipboard.
  • image NativeImage - Image to be written to the clipboard
let img = nativeImage.createFromPath('path_to_img_file');
eagle.clipboard.writeImage(img);

readImage()

Read image format content from the clipboard.
let input = nativeImage.createFromPath('path_to_img_file');
eagle.clipboard.writeImage(input);
let output = eagle.clipboard.readImage();

writeHTML(markup)

Write markup as HTML format to the clipboard.
  • markup string
eagle.clipboard.writeHTML('<b>Hi</b>');
console.log(eagle.clipboard.readHTML()); // <b>Hi</b>

readHTML()

Read HTML format content from the clipboard.
  • Returns string
eagle.clipboard.writeHTML('<b>Hi</b>');
console.log(eagle.clipboard.readHTML()); // <b>Hi</b>

copyFiles(paths)

Copy the specified files to the clipboard, supporting paste in file manager.
  • paths strings[] - Files to be copied to the clipboard.
eagle.clipboard.copyFiles([
'path_to_file',
'path_to_file2'
]);