@kanety/insert-text

1.1.0 • Public • Published

insert-text

Insert text to input or contenteditable element.

Installation

Install from npm:

$ npm install @kanety/insert-text --save

Usage

Insert text to textarea:

<textarea>sample text</textarea>
import InsertText from '@kanety/insert-text';
InsertText.run('textarea', 'YOUR TEXT');

Insert text to contenteditable element:

<div contenteditable="true">sample text</div>
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:

InsertText.run('textarea', 'YOUR TEXT', 'first');

Insert text at last position:

InsertText.run('textarea', 'YOUR TEXT', 'last');

License

The library is available as open source under the terms of the MIT License.

Readme

Keywords

Package Sidebar

Install

npm i @kanety/insert-text

Weekly Downloads

2

Version

1.1.0

License

MIT

Unpacked Size

48.3 kB

Total Files

23

Last publish

Collaborators

  • kanety