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

https://github.com/kathan/pasteable

Paste text into any HTML element.
https://github.com/kathan/pasteable

Last synced: about 1 year ago
JSON representation

Paste text into any HTML element.

Awesome Lists containing this project

README

          

# pasteable
Pasteable is a dependency free library that will allow you to paste text into any HTML element.
[Try it!](https://codepen.io/kathan-the-typescripter/pen/yLVaeMb)
## Pasteable Elements Can Receive Focus.
Click on the text input and it receives the focus...

![Ordinary Text Input](https://raw.githubusercontent.com/kathan/pasteable/master/img/ordinary_text_input.png)

...then click on the element using pasteable and it receives the focus.

![Div using pasteable](https://raw.githubusercontent.com/kathan/pasteable/master/img/div_using_pasteable.png)

## Example
In the "test" folder there is an Simple Grid Example using Angular.

Click..

![Click and paste](https://raw.githubusercontent.com/kathan/pasteable/master/img/click_and_paste.png)

...and paste!

![Click and paste](https://raw.githubusercontent.com/kathan/pasteable/master/img/pasted_data.png)

### HTML
```html








Simple Grid Example


Click and Paste Tab-Delimited Text Here



{{col}}



```
### Javascript
```javascript
var PasteApp = angular.module("PasteApp",[]);

PasteApp.controller('PasteCtrl', function ($scope, $http, $rootScope){
$scope.grid_data = [];
/************************************
* Initialize your pasteable element
************************************/
var s = pasteable({selectElement:'#my_element'});
s.addEventListener('paste', function(e){
/************************************
* Parse the pasted data into a multi-
* dimensional array and allow Angular
* template to render it into a grid.
************************************/
var rows = e.detail.split(/\n/);
for(var r in rows){
var columns = rows[r].split(/\t/);
$scope.grid_data.push(columns);
}
$scope.$apply();
});
});
```