Skip to content

rsp/deno-clipboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Deno clipboard library

Build Status
(CI tests on Linux, Mac, Windows)

Usage

import { clipboard } from 'https://deno.land/x/clipboard/mod.ts';

await clipboard.writeText('some text');

const text = await clipboard.readText();

console.log(text === 'some text'); // true

Goals

  • use Web Clipboard API
  • use readText and writeText (no read and write, see the spec)
  • work on Linux, macOS, Windows
  • don't bundle any binaries

It will spawn external processes so unfortunately it will require the all-powerful --allow-run flag.

If Deno exposes a Clipboard API (with new permissions like --allow-copy and --allow-paste) then hopefully this will be obsolete. See the relevant issue:

Notes

On Linux it requires xsel to be installed (probably installed by default).

The clipboard on Windows always adds a trailing newline if there was none which makes single line strings end with a newline and this module removes the trailing newline on Windows, but it means that if it was there originally then it will still be removed - to preserve single-line strings being single-line, but maybe this is not the right way to do it. The other option would be to preserve the trailing newline but also to get one if it wasn't there. Currently I chose to remove it because newlines in the clipboard sometimes are problematic (like automatically starting commands when pasted into the terminal). TODO: think about it.

Issues

For any bug reports or feature requests please post an issue on GitHub.

Author

Rafał Pocztarski
Follow on GitHub Follow on Twitter
Follow on Stack Exchange

License

MIT License (Expat). See LICENSE.md for details.

About

The clipboard copy/paste API for Deno

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published