npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@cdjs/js-clipboard

v0.0.3

Published

Control system clipboard via javascript

Downloads

4

Readme

js-clipboard

Control system clipboard via javascript

Installing

npm install @cdjs/js-clipboard
// or
yarn add @cdjs/js-clipboard

Usage

import jsClipboard from '@cdjs/js-clipboard'

Documentation

| Method | Desc | Args | Type | Return | Support Browser | | ------ | ------------------------------------------------------------------------ | ------------------------------------------------------------------------------ | ----------------------------------------- | ----------------------------------- | --------------------------------------------- | | get | 获取当前剪贴板内容 | - | - | PromisePromise | C: promotF: deniedS: denied | | copy | 复制 | target: 目标元素/文本/元素 id | HTMLElement/string | PromisePromise | C: grantedF: grantedS: granted | | cut | 剪切 | target: 目标元素/元素 id | HTMLElement/string | PromisePromise | C: grantedF: grantedS: granted | | paste | 粘贴 | target: 目标元素/元素 id | HTMLElement/string | PromisePromise | C: promotF: deniedS: denied | | deny | 禁止复制或粘贴,如果是作用于具体的元素,需要等元素渲染出来后再调用该方法 | target: 页面元素/ id/ class, 默认'document'action: 操作行为, 默认 'copy' | HTMLElement/string'copy' | 'paste' | void | C: grantedF: grantedS: granted | | add | 复制时自动加上文字,类似掘进的效果 | text: 目标文字target: 页面元素/ id/ class, 默认'document' | stringHTMLElement/string | void | C: grantedF: grantedS: granted |

Browser

  • C: Chrome
  • F: Firefox
  • S: Safari

Error 类型

  • denied: 系统不支持或权限不足
  • failed: web api 调用失败,具体原因未知
  • usage: api 调用异常

###How to use

#####获取剪贴板内容

jsClipboard
  .get()
  .then(str => {})
  .catch(err => {})
复制、剪切、粘贴
// paste cut 类似  注意传参
// copy 方法可以传入文字   paste / cut 只能传目标元素 或 元素id
jsClipboard
  .copy(target)
  .then(str => {})
  .catch(err => {})
禁止复制、粘贴
// 当 target 为具体的元素时,需要等元素渲染后在调用该方法
jsClipboard.deny(target)
追加文字
// 当 target 为具体的元素时,需要等元素渲染后在调用该方法
jsClipboard.add(
  '\n作者: XuKang\nGitHub: https://github.com/BlueBlueBlueSky/js-clipboard',
  target
)