Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kanety/insert-text
https://github.com/kanety/insert-text
Last synced: 2 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/kanety/insert-text
- Owner: kanety
- License: mit
- Created: 2021-09-26T06:27:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-06-27T02:05:14.000Z (7 months ago)
- Last Synced: 2024-10-02T02:51:47.455Z (4 months ago)
- Language: JavaScript
- Size: 17.6 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# insert-text
Insert text to input or contenteditable element.
## Installation
Install from npm:
$ npm install @kanety/insert-text --save
## Usage
Insert text to `textarea`:
```html
sample text
``````javascript
import InsertText from '@kanety/insert-text';
InsertText.run('textarea', 'YOUR TEXT');
```Insert text to `contenteditable` element:
```html
sample text
``````javascript
import InsertText from '@kanety/insert-text';
InsertText.run('div[contenteditable]', 'YOUR TEXT');
```Text is inserted at caret position by default.
### Options
Insert text at first position:
```javascript
InsertText.run('textarea', 'YOUR TEXT', 'first');
```Insert text at last position:
```javascript
InsertText.run('textarea', 'YOUR TEXT', 'last');
```## License
The library is available as open source under the terms of the [MIT License](http://opensource.org/licenses/MIT).