diff --git a/gulpfile.js b/gulpfile.js index 2a124115..3d5afe3a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -383,7 +383,7 @@ gulp.task('rollup-bundle', (cb) => { // See https://github.com/tinesoft/generator-ngx-library/TROUBLESHOUTING.md if trouble 'linkifyjs': _.camelCase('linkifyjs'.replace('/', '.')), 'linkifyjs/string': _.camelCase('linkifyjs/string'.replace('/', '.')), - 'inkifyjs/plugins/hashtag': _.camelCase('inkifyjs/plugins/hashtag'.replace('/', '.')), + 'inkifyjs/plugins/hashtag': _.camelCase('linkifyjsPluginsHashtag'.replace('/', '.')), // 'linkifyjs/plugins/hashtag': 'hashtag', }; diff --git a/src/module/interfaces/ngx-linkifyjs.interface.ts b/src/module/interfaces/ngx-linkifyjs.interface.ts index 065961dd..33d7b81f 100644 --- a/src/module/interfaces/ngx-linkifyjs.interface.ts +++ b/src/module/interfaces/ngx-linkifyjs.interface.ts @@ -3,3 +3,8 @@ export interface Link { value: string, href: string, } + +export interface NgxLinkifyjsConfig { + enableHash?: boolean, + enableMention?: boolean +} diff --git a/src/module/ngx-linkifyjs.module.ts b/src/module/ngx-linkifyjs.module.ts index 9b7da29a..bf16a982 100644 --- a/src/module/ngx-linkifyjs.module.ts +++ b/src/module/ngx-linkifyjs.module.ts @@ -12,6 +12,8 @@ import {NgxLinkifyjsPipe} from './pipes/ngx-linkifyjs.pipe'; // Export module's public API export {Link} from './interfaces/ngx-linkifyjs.interface'; +import {NgxLinkifyjsConfig} from './interfaces/ngx-linkifyjs.interface'; + export {LinkType} from './enum/linktype.enum'; export {NgxLinkifyjsPipe} from './pipes/ngx-linkifyjs.pipe'; export {NgxLinkifyjsService} from './service/ngx-linkifyjs.service'; @@ -25,7 +27,13 @@ export {NgxLinkifyjsService} from './service/ngx-linkifyjs.service'; }) export class NgxLinkifyjsModule { - static forRoot(): ModuleWithProviders { + private static DEFAULT_CONFIG: NgxLinkifyjsConfig = { + enableHash: true, + enableMention: true + }; + + static forRoot(config?: NgxLinkifyjsConfig): ModuleWithProviders { + Object.assign(this.DEFAULT_CONFIG, config); return { ngModule: NgxLinkifyjsModule, providers: [NgxLinkifyjsService] @@ -33,7 +41,16 @@ export class NgxLinkifyjsModule { } constructor() { - hashtag(linkify); - // mention(linkify); + this._handleConfig(); + } + + private _handleConfig() { + if (NgxLinkifyjsModule.DEFAULT_CONFIG.enableHash) { + hashtag(linkify); + } + + if (NgxLinkifyjsModule.DEFAULT_CONFIG.enableMention) { + mention(linkify); + } } }