npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-highlight-within-textarea

v3.2.2

Published

React component for highlighting text within a textarea

Downloads

31,854

Readme

react-highlight-within-textarea

React component for highlighting spans of text within a textarea

NPM JavaScript Style Guide Yarn Test

Install

npm install --save react-highlight-within-textarea
npm install --save draft-js
yarn add react-highlight-within-textarea
yarn add draft-js

Note: This has a peer dependency of draft-js.

Usage

import React from 'react';
import { useState } from 'react';
import { HighlightWithinTextarea } from 'react-highlight-within-textarea'

const Example = () => {
  const [value, setValue] = useState("X Y Z and then XYZ");
  const onChange = (value) => setValue(value);
  return (
    <HighlightWithinTextarea
      value={value}
      highlight={/[XYZ]/g}
      onChange= {onChange}
    />
  );
};

The highlight property accepts several different types of values to describe what will be highlighted. You can see the various ways to highlight things, along with example code, on the documentation and demo page.

Properties

The following properties are used directly by this library. Additional properties are passed unmodified directly to the Draft.js Editor Component.

value: This can either be the text value or a DraftJs EditorState.

onChange: This is called whenever the text value or selection changes. You must update value to accept this change. You only have to set the selection property if you want to change the current selection.

highlight: This specifies what to highlght. For more info, see the demo page.

selection: A selection containing anchor and focus that can be use to place the cursor or set selections.

ref: This returns a forwardRef to the underlying Draft.js Editor Component.

Properties passed directly to Draft.js Editor Component

The following properties are passed unmodified directly to the Draft.js Editor Component.

autoCapitalize autoComplete autoCorrect editorKey handleBeforeInput handleDrop handleDroppedFiles handleKeyCommand handlePastedFiles handlePastedText handleReturn keyBindingFn onBlur onFocus placeholder readOnly spellCheck stripPastedStyles textAlignment textDirectionality

Known and Potential Issues

The following have not yet been verified to work or have issues.

  • Form submit might not work. To be honest, I don't even know how React works with form submit buttons.
  • Accessible Rich Internet Applications ARIA may not be supported.
  • Reference forwarding probably works, but it hasn't been tested.
  • Tab between form elements may not work. I haven't looked into this at all.

Changes

See HISTORY.md

License

MIT © bonafideduck