react-autolink-text2
v3.3.0
Published
A React component for converting URLs in a given string of text into clicking link tags.
Downloads
4,827
Readme
<AutoLinkText />
A React component for converting URLs in a given string of text into clicking link tags.
The original package was published at OpenGov/react-autolink-text, but it seems to have been abandoned so I've published a fork to support ongoing development and keep up with new React versions.
Installation
npm install react-autolink-text2
Usage
import ReactDOM from 'react-dom';
import AutoLinkText from 'react-autolink-text2';
ReactDOM.render(
<AutoLinkText text='Check out this cool component: http://github.com/schneidmaster/react-autolink-text2' />,
document.body
);
Props
text
(string) -- text to be autolinked[disableUrlStripping]
(boolean) -- optional bypass of anchor text stripping[maxLength]
(number) -- optional max text length, after which the provided text will be truncated[linkProps]
(object) -- optional props to be set on generated link elements (target='_blank'
,rel='nofollow'
, custom classes, etc.)
Development
Prerequisites
- git
- npm
- yarn (optional/recommended)
Setup
- Clone the repository (
git clone [email protected]:schneidmaster/react-autolink-text.git
) - Install dependencies:
npm install
oryarn install
Testing
Run npm run examples
or yarn examples
and open http://localhost:8080. Make changes in src/index.js
or try different use cases in examples/app.js
.
Run npm test
or yarn test
to execute the jest test suite. An HTML code coverage report is automatically saved to /coverage/lcov-report/index.html
.
Run npm run lint
or yarn lint
to lint the codebase (using eslint).
Deployment
Run npm run build
or yarn build
to build an ES5 version of the package.
Contributing
- Fork it (https://github.com/schneidmaster/react-autolink-text/fork)
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request
Thanks
Thank you to @gregjacobs for creating Autolinker.js from which this component was based.