Skip to content

Commit

Permalink
feat(package): ability to pass an option object to linkifyjs #44
Browse files Browse the repository at this point in the history
  • Loading branch information
AnthonyNahas committed Jan 10, 2019
1 parent 53ea407 commit 8d46fe6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/module/ngx-linkifyjs.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export {Link} from './interfaces/ngx-linkifyjs.interface';
import {NgxLinkifyjsConfig} from './interfaces/ngx-linkifyjs.interface';

export {LinkType} from './enum/linktype.enum';
export {NgxLinkifyOptions} from './interfaces/ngx-linkifyjs.interface';
export {NgxLinkifyjsPipe} from './pipes/ngx-linkifyjs.pipe';
export {NgxLinkifyjsService} from './service/ngx-linkifyjs.service';

Expand Down
10 changes: 4 additions & 6 deletions src/module/pipes/ngx-linkifyjs.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,16 @@ import {Pipe, PipeTransform} from '@angular/core';

// @ts-ignore
import linkifyStr from 'linkifyjs/string';
import {NgxLinkifyOptions} from '../..';

@Pipe({
name: 'linkify'
})
export class NgxLinkifyjsPipe implements PipeTransform {

transform(value: any, args?: any): string {
return value ? linkifyStr(value, {
target: {
url: '_self'
}
}) : value;
transform(value: any, options?: NgxLinkifyOptions): string {
console.log('options: ', options);
return value ? linkifyStr(value, options) : value;
}

}
5 changes: 3 additions & 2 deletions src/module/service/ngx-linkifyjs.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@ import {Injectable} from '@angular/core';
// @ts-ignore
import * as linkify from 'linkifyjs';
import {Link} from '../..';
import {NgxLinkifyOptions} from '../interfaces/ngx-linkifyjs.interface';

@Injectable()
export class NgxLinkifyjsService {
constructor() {
}

linkify(text: string): string {
linkify(text: string, options?: NgxLinkifyOptions): string {
// @ts-ignore
return text.linkify();
return text.linkify(options);
}

find(text: string): Array<Link> {
Expand Down

0 comments on commit 8d46fe6

Please sign in to comment.