Gathering detailed insights and metrics for ngx-linkifyjs
Gathering detailed insights and metrics for ngx-linkifyjs
Gathering detailed insights and metrics for ngx-linkifyjs
Gathering detailed insights and metrics for ngx-linkifyjs
ngx-linkifyjs-v2
Angular wrapper for linkifyjs - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
@code-name-jack/ngx-linkifyjs
Angular wrapper for linkifyjs(v4) - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
@codenamejack/ngx-linkifyjs-v2
Angular wrapper for linkifyjs - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
npm install ngx-linkifyjs
Typescript
Module System
Node Version
NPM Version
53.7
Supply Chain
90.6
Quality
75.4
Maintenance
50
Vulnerability
98.6
License
HTML (46.13%)
TypeScript (40.91%)
JavaScript (8.14%)
CSS (4.81%)
Total Downloads
744,768
Last Day
128
Last Week
1,035
Last Month
4,917
Last Year
70,255
42 Stars
153 Commits
21 Forks
3 Watching
823 Branches
5 Contributors
Latest Version
1.3.0
Package Id
ngx-linkifyjs@1.3.0
Unpacked Size
61.73 kB
Size
12.33 kB
File Count
20
NPM Version
6.4.1
Node Version
10.15.0
Cumulative downloads
Total Downloads
Last day
-40.5%
128
Compared to previous day
Last week
-13%
1,035
Compared to previous week
Last month
20.9%
4,917
Compared to previous month
Last year
-43.4%
70,255
Compared to previous year
1
2
Do you have any question or suggestion ? Please do not hesitate to contact us! Alternatively, provide a PR | open an appropriate issue here
If you like this project, support ngx-linkifyjs by starring :star: and sharing it :loudspeaker:
View all the directives in action at https://anthonynahas.github.io/ngx-linkifyjs
Install above dependencies via npm.
Now install ngx-linkifyjs
via:
1npm i -s ngx-linkifyjs
Note:If you are using
SystemJS
, you should adjust your configuration to point to the UMD bundle. In your systemjs config file,map
needs to tell the System loader where to look forngx-linkifyjs
:
1map: { 2 'ngx-linkifyjs': 'node_modules/ngx-linkifyjs/bundles/ngx-linkifyjs.umd.js', 3}
Once installed you need to import the main module:
1import { NgxLinkifyjsModule } from 'ngx-linkifyjs';
The only remaining part is to list the imported module in your application module. The exact method will be slightly
different for the root (top-level) module for which you should end up with the code similar to (notice NgxLinkifyjsModule .forRoot()
):
1import { NgxLinkifyjsModule } from 'ngx-linkifyjs'; 2 3@NgModule({ 4 declarations: [AppComponent, ...], 5 imports: [NgxLinkifyjsModule.forRoot(), ...], 6 bootstrap: [AppComponent] 7}) 8export class AppModule { 9}
Other modules in your application can simply import NgxLinkifyjsModule
:
1import { NgxLinkifyjsModule } from 'ngx-linkifyjs'; 2 3@NgModule({ 4 declarations: [OtherComponent, ...], 5 imports: [NgxLinkifyjsModule, ...], 6}) 7export class OtherModule { 8}
Once the library is imported, you can use its components, directives and pipes in your Angular application:
ngx-linkifyjs
provides an appropriate option interface called NgxLinkifyOptions
to access the native options of the linkifyjs library
and all of them are optional
1 2import { NgxLinkifyOptions } from 'ngx-linkifyjs'; 3 4 const options: NgxLinkifyOptions = 5 { 6 attributes: null, 7 className: 'linkified', 8 defaultProtocol: 'http', 9 events: null, 10 format: function (value, type) { 11 return value; 12 }, 13 formatHref: function (href, type) { 14 return href; 15 }, 16 ignoreTags: [], 17 nl2br: false, 18 tagName: 'a', 19 target: { 20 url: '_blank' 21 }, 22 validate: true 23 };
{{text | linkify}}
1<span [innerHTML]="'Linkify the following URL: https://github.com/anthonynahas/ngx-linkifyjs and share it <3' | linkify"></span>
result: Linkify the following URL: https://github.com/anthonynahas/ngx-linkifyjs and share it <3
if you prefer to provide your own option to the pipe
, you can use it like the following:
{{text | linkify: 'options' }}
{{text | linkify: '{/*your options*/}' }}
{{text | linkify: '{target {url: "_self" }}' }}
Inject the NgxLinkifyjsService
service
1import {NgxLinkifyjsService, Link, LinkType} from 'ngx-linkifyjs'; 2 3constructor(public linkifyService: NgxLinkifyjsService) { 4 } 5}
Convert a basic text string to a valid linkified text
Params
text
: String
Text to linkify --> to convert with linksoptions
: NgxLinkifyjsService
options to pass it to the linkifyjs library and it's optionalReturns String
converted text with links
1import {NgxLinkifyjsService, Link, LinkType, NgxLinkifyOptions} from 'ngx-linkifyjs'; 2 3constructor(public linkifyService: NgxLinkifyjsService) { 4 5 const options: NgxLinkifyOptions = 6 { 7 className: 'linkifiedYES', 8 target : { 9 url : '_self' 10 } 11 }; 12 13 this.linkifyService.linkify('For help with GitHub.com, please email support@github.com'); 14 // result 1 --> see below 15 16 this.linkifyService.linkify('For help with GitHub.com, please email support@github.com', options); 17 // result 2 --> see below 18 } 19}
result 1
1'For help with <a href=\"http://github.com\" class=\"linkified\" target=\"_blank\">GitHub.com</a>, please email <a href=\"mailto:support@github.com\" class=\"linkified\">support@github.com</a>'
result 2
1'For help with <a href=\"http://github.com\" class=\"linkifiedYES\" target=\"_self\">GitHub.com</a>, please email <a href=\"mailto:support@github.com\" class=\"linkifiedYES\">support@github.com</a>'
find
methodFinds all links in the given string
Params
text
: String
search text stringReturns Array<Link>
List of links where each element is a hash with properties type, value, and href:
'url'
'email'
'hashtag'
(if Hashtag is enabled via config/default true
)'mention'
(if Mention is enabled via config/default true
)href
attribute.1import {Component, OnInit} from '@angular/core'; 2import {NgxLinkifyjsService, Link, LinkType} from 'ngx-linkifyjs'; 3 4@Component({ 5 selector: 'app-home', 6 templateUrl: './home.component.html', 7 styleUrls: ['./home.component.scss'] 8}) 9export class HomeComponent { 10 11 constructor(public linkifyService: NgxLinkifyjsService) { 12 const foundLinks: Link[] = this.linkifyService.find('Any links to github.com here? If not, contact test@example.com'); 13 14 // result - output --> see below 15 } 16 17}
1// Result 2[ 3 { 4 type: LinkType.URL, 5 value: 'github.com', 6 href: 'http://github.com' 7 }, 8 { 9 type: LinkType.EMAIL, 10 value: 'test@example.com', 11 href: 'mailto:test@example.com' 12 } 13]
test
methodIs the given string a link? Not to be used for strict validation - See Caveats
Params
value
: String
| Array<String>
Test stringReturns Boolean
1import {Component, OnInit} from '@angular/core'; 2import {NgxLinkifyjsService} from 'ngx-linkifyjs'; 3 4@Component({ 5 selector: 'app-home', 6 templateUrl: './home.component.html', 7 styleUrls: ['./home.component.scss'] 8}) 9export class HomeComponent { 10 11 constructor(public linkifyService: NgxLinkifyjsService) { 12 this.linkifyService.test('github.com'); // return true 13 this.linkifyService.test('dev@example.com'); // return true 14 this.linkifyService.test(['github.com', 'email']); // return false 15 this.linkifyService.test('helloWorld'); // return false 16 } 17}
The config argument is 100% optional, otherwise we will take the default values true
1import { NgxLinkifyjsModule } from 'ngx-linkifyjs'; 2 3@NgModule({ 4 declarations: [AppComponent, ...], 5 imports: [NgxLinkifyjsModule.forRoot( 6 { 7 enableHash: false, // optional - default true 8 enableMention: false // optional - default true 9 }), ...], 10 bootstrap: [AppComponent] 11}) 12export class AppModule { 13}
take a look @ @angular-material-extensions/link-preview which is using ngx-linkifyjs
1$ git clone https://github.com/AnthonyNahas/ngx-linkifyjs.git
1$ gulp steup
1$ cd demo
1$ npm i && npm start
http://localhost:4200/
Built by and for developers :heart: we will help you :punch:
This project is supported by jetbrains with 1 ALL PRODUCTS PACK OS LICENSE incl. webstorm
Copyright (c) 2018 Anthony Nahas. Licensed under the MIT License (MIT)
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
license file detected
Details
Reason
Found 1/29 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- 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
146 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-12-16
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