![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
react-highlight-within-textarea
Advanced tools
React component for highlighting text within a textarea
React component for highlighting spans of text within a textarea
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.
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.
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.
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
The following have not yet been verified to work or have issues.
See HISTORY.md
MIT © bonafideduck
FAQs
React component for highlighting text within a textarea
We found that react-highlight-within-textarea demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.