@napi-rs/clipboard
v1.1.2
Published
> ๐ Help me to become a full-time open-source developer by [sponsoring me on Github](https://github.com/sponsors/Brooooooklyn)
Downloads
5,714
Readme
@napi-rs/clipboard
๐ Help me to become a full-time open-source developer by sponsoring me on Github
Manipulate Clipboard in Node.js via native API.
It's a Node.js binding for 1Password/aboard with additions from rgwood/clipboard-anywhere
API
Text
import { Clipboard } from '@napi-rs/clipboard'
const clipboard = new Clipboard()
clipboard.setText('๐
')
clipboard.getText() // '๐
'
Image
import { join } from 'path'
import { fileURLToPath } from 'url'
import { Clipboard } from '@napi-rs/clipboard'
import { Transformer } from '@napi-rs/image'
const image = new Transformer(
readFileSync(join(fileURLToPath(import.meta.url), '..', 'test.png'))
)
const { width, height } = await image.metadata()
const rawPixels = await image.rawPixels()
// Only accept raw RGBA pixels
clipboard.setImage(width, height, image)
// You can paste image now