NodeJS addon that provides a convenient and easy-to-use interface for working with the system clipboard. It allows you to read and write text and files from/to the clipboard and provides event-based notifications for changes in the clipboard content.
Platforms: macos, windows, (linux wip)
Also supported in electron.
npm i clipeasy
To use clipeasy in your project, you need to require or import it, depending on your project setup.
const clipboard = new Clipboard()
console.log(clipboard.read()) // whatever is in the clipboard at the time
const clipboard = new Clipboard()
clipboard.write('Hello from the other side!')
console.log(clipboard.read()) // "Hello from the other side!"
The Clipboard
object extends EventEmitter
and inherits all of its useful members like on
, once
, addListener
, etc.
There are two events available to subscribe to:
text-changed
- when text has been copied.file-changed
- when files have been copied.
const clipboard = new Clipboard()
clipboard.on('text-changed', text => {
console.log('Clipboard text changed:', text)
})
clipboard.on('file-changed', paths => {
console.log('Clipboard file changed:', paths)
})
The Clipboard
object provides useful methods for interacting with the system clipboard:
Reads the text from the clipboard and returns it as a string.
Writes the given text to the clipboard.
Reads the file paths from the clipboard. (Note: Platform-specific support)
Writes the given file paths to the clipboard. (Note: Platform-specific support)
Clears the clipboard content.
Stops the clipboard change event monitoring.
Contributions are welcome! If you find any issues or have suggestions for improvement, please feel free to open an issue or submit a pull request.
Clipeasy is open-source and distributed under the MIT License. See the LICENSE file for more details.