0.0.2 • Published 4 years ago

@nandorojo/electron-clipboard v0.0.2

Weekly downloads
5
License
MIT
Repository
github
Last release
4 years ago

Electron Better Clipboard

For of extended clipboard.

It's the same, but it adds this function too:

import clipboard from "@nandorojo/electron-clipboard";

clipboard.setInterval(400); // default is 200

This lets you customize how often the interval checks for new items.

Electron clipboard extended with event handler for Text and Image change

yarn add @nandorojo/electron-clipboard

This library has all methods of electron's clipboard api with added functionalities for listening to changes in clipboard. As of now only Text and Image changes are captured.

Usage

import clipboard from "@nandorojo/electron-clipboard";

clipboard
  .on("text-changed", () => {
    let currentText = clipboard.readText();
  })
  .once("text-changed", () => {
    console.log("TRIGGERED ONLY ONCE");
  })
  .on("image-changed", () => {
    let image = clipboard.readImage();
    image.toDataURL();
  })
  .startWatching();

clipboard.off("text-changed");

clipboard.stopWatching();

Methods

All methods of electron's clipboard api plus the methods listed below

startWatching()

Returns clipboard - Chainable method, Only after startWatching is called changes to clipboard will be watched.

stopWatching()

Returns clipboard - Chainable method, Changes to clipboard will not be watched after calling this

on(event, listener), once(event, listener)

  • event String - Can be either text-changed or image-changed
  • listener Function - Callback function

Returns clipboard - Chainable method

off(event, listener)

  • event String - Can be either text-changed or image-changed
  • listener Function (optional) - If listener is not passed all listeners of the event will be removed

Returns clipboard - Chainable method