Giter VIP home page Giter VIP logo

deno-clipboard's Introduction

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.

deno-clipboard's People

Contributors

op-personal avatar rsp avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.