
Security News
Socket Releases Free Certified Patches for Critical vm2 Sandbox Escape
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.
highlight-in-textarea
Advanced tools
Library for highlighting bits of text within a textarea. Port of a plugin for jQuery to pure JS.
Library for highlighting bits of text within a textarea. Port of a plugin for jQuery to pure JS.
It's not actually possible to style text in a textarea, because any markup within a textarea is treated as literal text. This plugin aims to fake it, allowing you to highlight pieces of text inside a textarea.
A native textarea element is used and familiar behavior (auto-correct, scrolling, resizing, etc.) works as expected.
To start, create an instance of HighlightInTextarea, passing in an element, and a config object.
const hit = new HighlightInTextarea('.my-textarea', {
highlight: whatever // string, regexp, array, function, or custom object
});
The highlight property accepts several types of values to describe what will be highlighted. You can see the various ways to highlight things, along with example code, on the demo page.
For reference, the demo page has some sample styling (view source to see the CSS).
There are some guidelines for getting your styles in the right places. Here are the classes you'll want to use.
Use for visibility, positioning, and background.
displaypositiontopleftmarginbackgroundUse for sizing and text formatting.
widthheightpaddingbordercolorfontUse for highlighted text. Generally, stuff that doesn't change size is fine.
background-colorborder-radiusbox-shadowChanges to color won't be visible, since text in the textarea covers colored text in the highlights.
You can remove the plugin from a textarea with this.
const hit = new HighlightInTextarea('.my-textarea', {
highlight: whatever // string, regexp, array, function, or custom object
});
hit.destroy();
FAQs
Library for highlighting bits of text within a textarea. Port of a plugin for jQuery to pure JS.
We found that highlight-in-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
A critical vm2 sandbox escape can allow untrusted JavaScript to break isolation and execute commands on the host Node.js process.

Research
Five malicious NuGet packages impersonate Chinese .NET libraries to deploy a stealer targeting browser credentials, crypto wallets, SSH keys, and local files.

Security News
pnpm 11 turns on a 1-day Minimum Release Age and blocks exotic subdeps by default, adding safeguards against fast-moving supply chain attacks.