Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/freeshineit/react-clipboardjs-copy

react copy/cut component
https://github.com/freeshineit/react-clipboardjs-copy

clipboardjs component-library copy cut npm react react-dom

Last synced: 11 days ago
JSON representation

react copy/cut component

Awesome Lists containing this project

README

        

# react-clipboardjs-copy

![build](https://github.com/freeshineit/react-clipboardjs-copy/workflows/build/badge.svg) ![Download](https://img.shields.io/npm/dm/react-clipboardjs-copy.svg) ![Version](https://img.shields.io/npm/v/react-clipboardjs-copy.svg) ![License](https://img.shields.io/npm/l/react-clipboardjs-copy.svg)

A react copy component that based on `clipboard.js`

[中文](./README_zh-CN.md)

## Installing

```sh
npm install --save react-clipboardjs-copy
```

## Basic usage

```jsx
import React from 'react';
import ReactClipboard from 'react-clipboardjs-copy';
import './App.css';
export default class App extends React.Component {
render() {
return (



Copy text

{}} onError={() => {}}>
{
console.log('click button');
}}
>
Copy Text





Mussum ipsum cacilds...


{}} onError={() => {}}>
Cut



);
}
}
```

```jsx


Copy Input value

```

## Options(props)

| Property | Description | Type | Default |
| --- | --- | --- | --- |
| action | Overwrites default command (`cut` or `copy`) , Corresponding to clipboard.js attribute data-clipboard-action. | `cut` \| `copy` | `copy` |
| target | React component will copy target element content. Corresponding to `clipboard.js` attribute `data-clipboard-target`. | string \| function(elem: Element): Element | - |
| text | React component will copy content. Corresponding to `clipboard.js` attribute `data-clipboard-text` | string \| function(elem: Element): string | |
| container | For use in Bootstrap Modals or with any other library that changes the focus you'll want to set the focused element as the container value. | Element | `body` |
| selection | Setting whether to clear the copy or cut selected | boolean | false |
| onSuccess | Operation success callback | function(event?: ClipboardJS.Event): void | - |
| onError | Operation error callback | function(event?: ClipboardJS.Event): void | - |

## Developing

```sh
git clone [email protected]:freeshineit/react-clipboardjs-copy.git

cd react-clipboardjs-copy

pnpm install

## development
pnpm run dev

## test
pnpm run test

## production
pnpm run build
```

## Reference material

[clipboard.js](https://clipboardjs.com/)

## License

MIT © [Shine Shao](https://github.com/freeshineit)