Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
insert-text-textarea
Advanced tools
Readme
Insert text in a
textarea
andinput[type=text]
(supports Firefox and Undo, where possible)
The text will be inserted after the cursor or it will replace any text that's selected, acting like a paste
would.
You should use this instead of setting the field.value
directly because:
input
event (with event.inputType === 'insertText'
)It uses document.execCommand('insertText')
in Chrome (which has Undo support) and it replicates its behavior in Firefox (without Undo support until this bug is solved).
If you need IE support, use insert-text-at-cursor.
You can just download the standalone bundle
Or use npm
:
npm install insert-text-textarea
// This module is only offered as a ES Module
import insertText from 'insert-text-textarea';
Insert text at the cursor, replacing any possible selected text:
const textarea = document.querySelector('textarea');
const button = document.querySelector('.js-add-signature');
button.addEventListener(event => {
insertText(textarea, 'Made by 🐝 with pollen.');
});
This will wrap the selected text (if any) with **
on both sides:
const textarea = document.querySelector('textarea');
const button = document.querySelector('.js-markdown-make-text-bold');
button.addEventListener(event => {
// Don't use `getSelection()` if you want Firefox support
const selectedText = value.slice(
textarea.selectionStart,
textarea.selectionEnd
);
insertText(textarea, '**' + selectedText + '**');
});
This will replace the entire content, equivalent to field.value = 'New text!'
but with undo support:
const textarea = document.querySelector('textarea');
textarea.select(); // The text needs to be selected so it will be replaced
insertText(textarea, 'New text!');
<textarea>
, in a few bytes. Uses this module.<textarea>
to fit its content, in a few bytes.FAQs
Insert text in a textarea and input[text] (supports Firefox and Undo, where possible)
The npm package insert-text-textarea receives a total of 204 weekly downloads. As such, insert-text-textarea popularity was classified as not popular.
We found that insert-text-textarea demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.