1.1.0 • Published 1 year ago
@kanety/insert-text v1.1.0
insert-text
Insert text to input or contenteditable element.
Installation
Install from npm:
$ npm install @kanety/insert-text --saveUsage
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.