ngx-linkifyjs-v2
Version:
Angular wrapper for linkifyjs - library for finding links in plain text and converting them to HTML <a> tags via linkifyjs
1 lines • 6.86 kB
Source Map (JSON)
{"version":3,"file":"ngx-linkifyjs-v2.mjs","sources":["../../../projects/ngx-linkifyjs-v2/src/lib/enum/linktype.enum.ts","../../../projects/ngx-linkifyjs-v2/src/lib/pipes/ngx-linkifyjs.pipe.ts","../../../projects/ngx-linkifyjs-v2/src/lib/service/ngx-linkifyjs.service.ts","../../../projects/ngx-linkifyjs-v2/src/lib/ngx-linkifyjs.module.ts","../../../projects/ngx-linkifyjs-v2/src/public-api.ts","../../../projects/ngx-linkifyjs-v2/src/ngx-linkifyjs-v2.ts"],"sourcesContent":["export enum LinkType {\n URL = 'url',\n HASHTAG = 'hashtag',\n MENTION = 'mention',\n EMAIL = 'email',\n}\n","import {Pipe, PipeTransform} from '@angular/core';\nimport {NgxLinkifyOptions} from '../interfaces/ngx-linkifyjs.interface';\nimport linkifyStr from 'linkify-string';\n\n@Pipe({\n name: 'linkify',\n standalone: false\n})\nexport class NgxLinkifyjsPipe implements PipeTransform {\n\n transform(value: string, options?: NgxLinkifyOptions): string {\n return value ? linkifyStr(value, options) : value;\n }\n\n}\n","import {Injectable} from '@angular/core';\nimport * as linkify from 'linkifyjs';\nimport linkifyStr from 'linkify-string';\nimport {Link, NgxLinkifyOptions} from '../interfaces/ngx-linkifyjs.interface';\n\n@Injectable()\nexport class NgxLinkifyjsService {\n constructor() {\n }\n\n /**\n * Convert the passed text as a string to an appropriate url\n *\n * @param text - the string to convert\n * @param options - options to pass it to the linkifyjs library\n */\n linkify(text: string, options?: NgxLinkifyOptions): string {\n return linkifyStr(text, options);\n }\n\n /**\n * Find any links in a given text as a string\n *\n * @param text - the string to find some links\n */\n find(text: string): Array<Link> {\n return linkify.find(text);\n }\n\n /**\n * Test if a given value is a link or an array of all links\n *\n * @param value - the value to test\n */\n test(value: string | string[]): boolean {\n if (typeof value === 'string') {\n return linkify.test(value);\n }\n return value.find(v => !linkify.test(v)) === undefined;\n }\n\n}\n","import {CommonModule} from '@angular/common';\nimport {Inject, InjectionToken, ModuleWithProviders, NgModule} from '@angular/core';\n// TODO REMOVE ME\n// import * as linkify from 'linkifyjs';\n// import hashtag from 'linkify-plugin-hashtag';\n// import mention from 'linkify-plugin-mention';\n\nimport {NgxLinkifyjsService} from './service/ngx-linkifyjs.service';\nimport {NgxLinkifyjsPipe} from './pipes/ngx-linkifyjs.pipe';\n\n// Export module's public API\nexport {Link} from './interfaces/ngx-linkifyjs.interface';\nimport {NgxLinkifyjsConfig} from './interfaces/ngx-linkifyjs.interface';\n\nexport {LinkType} from './enum/linktype.enum';\nexport {NgxLinkifyOptions} from './interfaces/ngx-linkifyjs.interface';\nexport {NgxLinkifyjsPipe} from './pipes/ngx-linkifyjs.pipe';\nexport {NgxLinkifyjsService} from './service/ngx-linkifyjs.service';\n\nexport const NgxLinkifyjsConfigToken = new InjectionToken<NgxLinkifyjsConfig>('NgxLinkifyjsConfig');\nexport const DEFAULT_CONFIG: NgxLinkifyjsConfig = {enableHash: true, enableMention: true};\n\n@NgModule({\n imports: [\n CommonModule\n ],\n exports: [NgxLinkifyjsPipe],\n declarations: [NgxLinkifyjsPipe]\n})\nexport class NgxLinkifyjsModule {\n\n static forRoot(config: NgxLinkifyjsConfig = DEFAULT_CONFIG): ModuleWithProviders<NgxLinkifyjsModule> {\n return {\n ngModule: NgxLinkifyjsModule,\n providers:\n [\n NgxLinkifyjsService,\n {\n provide: NgxLinkifyjsConfigToken,\n useValue: config\n },\n ]\n };\n }\n\n constructor(@Inject(NgxLinkifyjsConfigToken)\n public config: NgxLinkifyjsConfig) {\n // TODO REMOVE ME\n // if (config.enableHash) {\n // hashtag(linkify);\n // }\n //\n // if (config.enableMention) {\n // mention(linkify);\n // }\n }\n\n}\n","/*\n * Public API Surface of ngx-linkifyjs\n */\n\nexport * from './lib/enum/linktype.enum';\nexport * from './lib/interfaces/ngx-linkifyjs.interface';\nexport * from './lib/pipes/ngx-linkifyjs.pipe';\nexport * from './lib/service/ngx-linkifyjs.service';\nexport * from './lib/ngx-linkifyjs.module';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;IAAY;AAAZ,CAAA,UAAY,QAAQ,EAAA;AAClB,IAAA,QAAA,CAAA,KAAA,CAAA,GAAA,KAAW;AACX,IAAA,QAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,QAAA,CAAA,SAAA,CAAA,GAAA,SAAmB;AACnB,IAAA,QAAA,CAAA,OAAA,CAAA,GAAA,OAAe;AACjB,CAAC,EALW,QAAQ,KAAR,QAAQ,GAKnB,EAAA,CAAA,CAAA;;MCGY,gBAAgB,CAAA;IAE3B,SAAS,CAAC,KAAa,EAAE,OAA2B,EAAA;AAClD,QAAA,OAAO,KAAK,GAAG,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC,GAAG,KAAK;;uGAHxC,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA,eAAA,CAAA,IAAA,EAAA,CAAA;qGAAhB,gBAAgB,EAAA,YAAA,EAAA,KAAA,EAAA,IAAA,EAAA,SAAA,EAAA,CAAA;;2FAAhB,gBAAgB,EAAA,UAAA,EAAA,CAAA;kBAJ5B,IAAI;AAAC,YAAA,IAAA,EAAA,CAAA;AACF,oBAAA,IAAI,EAAE,SAAS;AACf,oBAAA,UAAU,EAAE;AACf,iBAAA;;;MCDY,mBAAmB,CAAA;AAC9B,IAAA,WAAA,GAAA;;AAGA;;;;;AAKG;IACH,OAAO,CAAC,IAAY,EAAE,OAA2B,EAAA;AAC/C,QAAA,OAAO,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC;;AAGlC;;;;AAIG;AACH,IAAA,IAAI,CAAC,IAAY,EAAA;AACf,QAAA,OAAO,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC;;AAG3B;;;;AAIG;AACH,IAAA,IAAI,CAAC,KAAw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