Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/stimulus-pastezone
https://github.com/kanety/stimulus-pastezone
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/stimulus-pastezone
- Owner: kanety
- License: mit
- Created: 2022-04-16T02:44:07.000Z (almost 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T07:30:55.000Z (7 months ago)
- Last Synced: 2024-11-02T04:32:49.315Z (3 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# stimulus-pastezone
A stimulus controller to paste clipboard data to input tag using Ctrl+V.
## Dependencies
* @hotwired/stimulus 3.0+
## Installation
Install from npm:
$ npm install @kanety/stimulus-pastezone --save
## Usage
Register controller:
```javascript
import { Application } from '@hotwired/stimulus';
import PastezoneController from '@kanety/stimulus-pastezone';const application = Application.start();
application.register('pastezone', PastezoneController);
```Build html as follows:
```html
Paste here
```Pasted clipboard data will be set in the input tag:
### Callbacks
Run callbacks when clipboard data is pasted:
```javascript
let element = document.querySelector('[data-controller="pastezone"]');
element.addEventListener('pastezone:pasted', e => {
// e.detail.files are pasted data
console.log("pasted " + e.detail.files);
});
```### Limitations
Firefox supports only image data in clipboard.
## License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).