Plugin API
English
English
  • Getting Started
    • Introduction
    • Your First Plugin
    • File Structure Overview
    • Plugin Types
      • Window
      • Background Service
      • Format Extension
      • Inspector
    • Debug Plugin
  • Distribution
    • Prepare Plugin
    • Package Plugin
    • Publish Plugin
    • Update Plugin
    • Developer Policies
    • Plugin Icon Template
  • Developer Guide
    • manifest.json Configuration
    • Retrieve Data
    • Modify Data
    • Access Local Files
    • Issue Network Requests
    • Using Node.js Native API
    • Using Third-Party Modules
    • Multilingual (i18n)
    • Frameless Window
  • API Reference
    • event
    • item
    • folder
    • tag
    • tagGroup
    • library
    • window
    • app
    • os
    • screen
    • notification
    • contextMenu
    • dialog
    • clipboard
    • drag
    • shell
    • log
  • Extra Moudle
    • FFmpeg
Powered by GitBook
On this page
  • Methods
  • clear()
  • has(format)
  • writeText(text)
  • readText()
  • writeBuffer(format, buffer)
  • readBuffer(format)
  • writeImage(image)
  • readImage()
  • writeHTML(markup)
  • readHTML()
  • copyFiles(paths)
  1. API Reference

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(eagle.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.

  • Returns NativeImage

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'
]);

PreviousdialogNextdrag

Last updated 4 months ago