react-text-format
React component to parse urls, emails, credit cards, phone in text into clickable links or required format.
Installation
yarn add react-text-format
or
npm install react-text-format --save
Props
Name | Type | Default |
---|---|---|
allowedFormats | Array ['URL', 'Email', 'Image', 'Phone', 'CreditCard'] |
['URL', 'Email', 'Phone'] |
linkTarget | String (_blank | _self | _parent | _top | framename) | _self |
LinkDecorator | React.Node (decoratedHref: string, decoratedText: string, linkTarget: string, key: number) | Output Format: <a href="{URL}" target="{target}" rel='noopener' className='rtfLink'> <URL> </a> |
EmailDecorator | React.Node (decoratedHref: string, decoratedText: string,key: number) | Output Format:<a href="mailto: {EMAIL ADDRESS}" className='rtfEmail'> {EMAIL ADDRESS} </a> |
PhoneDecorator | React.Node (decoratedText: string, key: number) | Output Format<a href="tel:{PHONE NUMBER}" className='rtfEmail'> {PHONE NUMBER} </a> |
CreditCardDecorator | React.Node (decoratedText: string, key: number) | Output Format: <span className='rtfCreditCard'> {CREDIT CARD NUMBER} </span> |
ImageDecorator | React.Node (decoratedURL: string, key: number) | Output Format: <img src="{URL OF IMAGE}" rel='noopener' className='rtfImage' /> |