Gathering detailed insights and metrics for react-text-format
Gathering detailed insights and metrics for react-text-format
Gathering detailed insights and metrics for react-text-format
Gathering detailed insights and metrics for react-text-format
React component to parse urls, emails, credit cards, phone in text into clickable links or required format
npm install react-text-format
Typescript
Module System
Min. Node Version
Node Version
NPM Version
75.6
Supply Chain
94.8
Quality
75.7
Maintenance
100
Vulnerability
99.6
License
JavaScript (97.94%)
HTML (1.42%)
CSS (0.63%)
Total Downloads
253,655
Last Day
26
Last Week
613
Last Month
3,737
Last Year
63,289
MIT License
16 Stars
63 Commits
8 Forks
2 Watchers
9 Branches
3 Contributors
Updated on Apr 16, 2024
Minified
Minified + Gzipped
Latest Version
2.0.32
Package Id
react-text-format@2.0.32
Unpacked Size
840.98 kB
Size
186.01 kB
File Count
7
NPM Version
9.5.1
Node Version
18.16.0
Published on
Jan 05, 2024
Cumulative downloads
Total Downloads
Last Day
36.8%
26
Compared to previous day
Last Week
-36%
613
Compared to previous week
Last Month
-56.5%
3,737
Compared to previous month
Last Year
23.4%
63,289
Compared to previous year
3
3
29
React Component to find and parse links, emails, phone numbers, image's URL, credit cards and keywords to required format.
yarn add react-text-format
or
npm install react-text-format --save
1import ReactTextFormat from 'react-text-format'; 2 3React.render( 4 <ReactTextFormat> 5 This is demo link http://www.google.com 6 This is demo email <span data-email="miller@yahoo.com">miller@yahoo.com</span> 7 8 This is demo image https://preview.ibb.co/hqhoyA/lexie-barnhorn-1114350-unsplash.jpg 9 10 This is demo credit Card 5555555555554444 11 This is demo phone Number 123.456.7890 12 This is demo phone Number (212) 555 1212 13 This is demo phone Number (212) 555-1212 14 This is demo phone Number 212-555-1212 ext. 101 15 This is demo phone Number 212 555 1212 x101 16 17 This is an anchor <a href="http://formatter.com">http://formatter.com</a>; 18 </ReactTextFormat>, 19 document.body 20);
1import ReactTextFormat from 'react-text-format'; 2 3customLinkDecorator = ( 4 decoratedHref: string, 5 decoratedText: string, 6 linkTarget: string 7 ): React.Node => { 8 return ( 9 <a 10 href={decoratedHref} 11 12 target={linkTarget} 13 rel='noopener' 14 className='customLink' 15 > 16 {decoratedText} 17 </a> 18 ) 19 } 20 21customImageDecorator = ( 22 decoratedURL: string 23 ): React.Node => { 24 return ( 25 <div> 26 <img src={decoratedURL} rel='noopener' width="100" className='customImage' /> 27 </div> 28) 29} 30 31customEmailDecorator = ( 32 decoratedHref: string, 33 decoratedText: string 34 ): React.Node => { 35 return ( 36 <a href={decoratedHref} className='customEmail'> 37 {decoratedText} 38 </a> 39 ) 40} 41 42customPhoneDecorator = ( 43 decoratedText: string 44 ): React.Node => { 45 return ( 46 <a href={`tel:${decoratedText}`} className='customPhone'> 47 {decoratedText} 48 </a> 49 ) 50} 51 52customCreditCardDecorator = ( 53 decoratedText: string 54 ): React.Node => { 55 return ( 56 <i className='customCreditCard'> 57 <b>{decoratedText}</b> 58 </i> 59 ) 60} 61 62customTermDecorator = (decoratedText: string): React.Node => { 63 return ( 64 <b className="keyword"> 65 {decoratedText} 66 </b> 67 ); 68}; 69 70React.render( 71 <ReactTextFormat 72 allowedFormats={['URL', 'Email', 'Image', 'Phone', 'CreditCard']} 73 linkDecorator={customLinkDecorator} 74 emailDecorator={customEmailDecorator} 75 phoneDecorator={customPhoneDecorator} 76 creditCardDecorator={customCreditCardDecorator} 77 imageDecorator={customImageDecorator} 78 terms={["Link", "phone", "image", "Anchor", "email", "Credit"]} 79 > 80 This is demo link http://www.google.com 81 This is encoded Link http://go%2Emsn%2Ecom/nl/133942%2Easp 82 This is demo email <span data-email="miller@yahoo.com">miller@yahoo.com</span> 83 84 This is demo image 85 https://preview.ibb.co/hqhoyA/lexie-barnhorn-1114350-unsplash.jpg 86 87 This is demo credit Card 5555555555554444 88 89 This is demo phone Number 123.456.7890 90 This is demo phone Number (212) 555 1212 91 This is demo Phone Number (212) 555-1212 92 This is demo phone Number 212-555-1212 ext. 101 93 This is demo phone Number 212 555 1212 x101 94 95 This is an anchor <a href="http://formatter.com">http://formatter.com</a>; 96 </ReactTextFormat>, 97 document.body 98);
Name | Type | Default |
---|---|---|
allowedFormats | Array ['URL', 'Email', 'Image', 'Phone', 'CreditCard', 'Term'] | ['URL', 'Email', 'Phone', 'Term'] |
linkTarget | String (_blank | _self | _parent | _top | framename) | _self |
terms | Array of strings | [] |
linkDecorator | React.Node (decoratedHref: string, decoratedText: string, linkTarget: string) | Output Format: <a href="{URL}" target="{target}" rel='noopener' className='rtfLink'> <URL> </a> |
emailDecorator | React.Node (decoratedHref: string, decoratedText: string) | Output Format:<a href="mailto: {EMAIL ADDRESS}" className='rtfEmail'> {EMAIL ADDRESS} </a> |
phoneDecorator | React.Node (decoratedText: string) | Output Format<a href="tel:{PHONE NUMBER}" className='rtfEmail'> {PHONE NUMBER} </a> |
creditCardDecorator | React.Node (decoratedText: string) | Output Format: <span className='rtfCreditCard'> {CREDIT CARD NUMBER} </span> |
imageDecorator | React.Node (decoratedURL: string) | Output Format: <img src="{URL OF IMAGE}" rel='noopener' className='rtfImage' /> |
termDecorator | React.Node (decoratedText: string) | Output Format: <span className='rtfTerm'>{decoratedText}</span> |
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 1/30 approved changesets -- score normalized to 0
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
project is not fuzzed
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
74 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-06-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More