Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sinchang/pure-copyright
©️ add a reference to the source in buffer when copying
https://github.com/sinchang/pure-copyright
copy copyright javascript paste
Last synced: 7 days ago
JSON representation
©️ add a reference to the source in buffer when copying
- Host: GitHub
- URL: https://github.com/sinchang/pure-copyright
- Owner: sinchang
- License: mit
- Created: 2017-04-27T15:50:04.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2018-01-05T11:24:06.000Z (almost 7 years ago)
- Last Synced: 2024-12-23T04:47:31.826Z (11 days ago)
- Topics: copy, copyright, javascript, paste
- Language: JavaScript
- Homepage: http://copyright.surge.sh/
- Size: 45.9 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# pure-copyright
[![NPM version](https://img.shields.io/npm/v/pure-copyright.svg?style=flat)](https://npmjs.com/package/pure-copyright)
[![NPM downloads](https://img.shields.io/npm/dm/pure-copyright.svg?style=flat)](https://npmjs.com/package/pure-copyright)> pure JavaScript version of [copyright](https://github.com/absentik/copyright)
## Install
```bash
npm i -S pure-copyright
```## Usage
```js
import Copyright from 'pure-copyright'or
new Copyright(document.body)
```## Options
You can pass an options object in plugin init method.
* `text` : The text that will be added when copying (Default: `"
Original: " + window.location.href`);
* `minlength` : The minimum length of the copied text when running the plugin (Default: `0`).
* `processing` : Function to process the copied text (Default: `undefined`).```js
new Copyright(document.body, {
text: "
Reference: " + window.location.href,
minlength: 100,
processing: function(text) {
console.log(text)
}
})
```## Methods:
- destory:Stop the plugin
## Events:
You can listen Copyright events.
* `beforeCopy`
* `afterCopy````js
new Copyright(document.body, {
processing: function (text) {
console.log(text)
}
}).on('beforeCopy', () => {
console.log(+ new Date())
}).on('afterCopy', () => {
console.log(+ new Date())
})
```## Contributing
1. Fork it!
2. Create your feature branch: `git checkout -b my-new-feature`
3. Commit your changes: `git commit -am 'Add some feature'`
4. Push to the branch: `git push origin my-new-feature`
5. Submit a pull request :D## Credits
- [copyright](https://github.com/absentik/copyright)
## Author
**pure-copyright** © [sinchang](https://github.com/sinchang), Released under the [MIT](./LICENSE) License.
Authored and maintained by sinchang with help from contributors ([list](https://github.com/sinchang/copyright/contributors)).> [sinchang.me](https://sinchang.me) · GitHub [@sinchang](https://github.com/sinchang) · Twitter [@sinchangwen](https://twitter.com/sinchangwen)