@code-name-jack/ngx-linkifyjs 20.0.2 → 20.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -17,7 +17,7 @@
17
17
  - #️⃣ **Hashtags** - Linkify hashtags for social media content
18
18
  - @ **Mentions** - Convert @mentions to links
19
19
  - 🎨 **Customizable** - Full control over link styling and behavior
20
- - 🚀 **Angular 20** - Built for modern Angular with standalone component support
20
+ - 🚀 **Angular 20+** - Built for modern Angular with standalone-first architecture
21
21
  - 📦 **Tree-shakeable** - Optimized bundle size
22
22
  - 🔧 **TypeScript** - Full type safety
23
23
 
@@ -36,26 +36,40 @@ A comprehensive demo application is available in the [repository](https://github
36
36
  ### Option 1: Using Angular Schematics (Recommended)
37
37
 
38
38
  ```bash
39
- ng add ngx-linkifyjs
39
+ ng add @code-name-jack/ngx-linkifyjs
40
40
  ```
41
41
 
42
42
  ### Option 2: Using npm
43
43
 
44
44
  ```bash
45
- npm install ngx-linkifyjs
45
+ npm install @code-name-jack/ngx-linkifyjs
46
46
  ```
47
47
 
48
48
  ---
49
49
 
50
50
  ## 🚀 Quick Start
51
51
 
52
- ### For Standalone Components (Angular 14+)
52
+ **1. Configure in your app (app.config.ts):**
53
53
 
54
- **1. Import the pipe in your component:**
54
+ ```typescript
55
+ import { ApplicationConfig } from '@angular/core';
56
+ import { provideNgxLinkifyjs } from '@code-name-jack/ngx-linkifyjs';
57
+
58
+ export const appConfig: ApplicationConfig = {
59
+ providers: [
60
+ provideNgxLinkifyjs({
61
+ enableHash: true, // Enable hashtag detection
62
+ enableMention: true // Enable @mention detection
63
+ })
64
+ ]
65
+ };
66
+ ```
67
+
68
+ **2. Import the pipe in your component:**
55
69
 
56
70
  ```typescript
57
71
  import { Component } from '@angular/core';
58
- import { NgxLinkifyjsPipe } from 'ngx-linkifyjs';
72
+ import { NgxLinkifyjsPipe } from '@code-name-jack/ngx-linkifyjs';
59
73
 
60
74
  @Component({
61
75
  selector: 'app-example',
@@ -70,19 +84,20 @@ export class ExampleComponent {
70
84
  }
71
85
  ```
72
86
 
73
- **2. Using the service:**
87
+ **3. Using the service:**
74
88
 
75
89
  ```typescript
76
- import { Component } from '@angular/core';
77
- import { NgxLinkifyjsService } from 'ngx-linkifyjs';
90
+ import { Component, inject } from '@angular/core';
91
+ import { NgxLinkifyjsService } from '@code-name-jack/ngx-linkifyjs';
78
92
 
79
93
  @Component({
80
94
  selector: 'app-example',
81
- standalone: true,
82
- providers: [NgxLinkifyjsService]
95
+ standalone: true
83
96
  })
84
97
  export class ExampleComponent {
85
- constructor(private linkifyService: NgxLinkifyjsService) {
98
+ private linkifyService = inject(NgxLinkifyjsService);
99
+
100
+ constructor() {
86
101
  // Find all links
87
102
  const links = this.linkifyService.find('Visit github.com');
88
103
  // Output: [{ type: 'url', value: 'github.com', href: 'http://github.com' }]
@@ -96,22 +111,7 @@ export class ExampleComponent {
96
111
  }
97
112
  ```
98
113
 
99
- ### For NgModule-based Applications
100
-
101
- ```typescript
102
- import { NgModule } from '@angular/core';
103
- import { NgxLinkifyjsModule } from 'ngx-linkifyjs';
104
-
105
- @NgModule({
106
- imports: [
107
- NgxLinkifyjsModule.forRoot({
108
- enableHash: true, // Enable hashtag detection
109
- enableMention: true // Enable @mention detection
110
- })
111
- ]
112
- })
113
- export class AppModule { }
114
- ```
114
+ > **Note:** Since `NgxLinkifyjsService` uses `providedIn: 'root'`, it's automatically available once you add `provideNgxLinkifyjs()` to your app config. The `provideNgxLinkifyjs()` function is only needed to configure plugin options (hashtags/mentions).
115
115
 
116
116
  ---
117
117
 
@@ -130,7 +130,7 @@ The `linkify` pipe transforms text into linkified HTML:
130
130
  ```
131
131
 
132
132
  ```typescript
133
- import { NgxLinkifyOptions } from 'ngx-linkifyjs';
133
+ import { NgxLinkifyOptions } from '@code-name-jack/ngx-linkifyjs';
134
134
 
135
135
  export class MyComponent {
136
136
  text = 'Check out github.com and follow @angular!';
@@ -259,7 +259,7 @@ interface NgxLinkifyOptions {
259
259
  ### Example: Custom Configuration
260
260
 
261
261
  ```typescript
262
- import { NgxLinkifyOptions } from 'ngx-linkifyjs';
262
+ import { NgxLinkifyOptions } from '@code-name-jack/ngx-linkifyjs';
263
263
 
264
264
  export class MyComponent {
265
265
  options: NgxLinkifyOptions = {
@@ -298,7 +298,7 @@ Configure hashtag and mention support globally:
298
298
  ```typescript
299
299
  // For standalone apps (in app.config.ts)
300
300
  import { ApplicationConfig } from '@angular/core';
301
- import { NgxLinkifyjsService, NgxLinkifyjsConfigToken } from 'ngx-linkifyjs';
301
+ import { NgxLinkifyjsService, NgxLinkifyjsConfigToken } from '@code-name-jack/ngx-linkifyjs';
302
302
 
303
303
  export const appConfig: ApplicationConfig = {
304
304
  providers: [
@@ -313,18 +313,17 @@ export const appConfig: ApplicationConfig = {
313
313
  ]
314
314
  };
315
315
 
316
- // For NgModule apps
317
- import { NgxLinkifyjsModule } from 'ngx-linkifyjs';
316
+ // In app.config.ts
317
+ import { provideNgxLinkifyjs } from '@code-name-jack/ngx-linkifyjs';
318
318
 
319
- @NgModule({
320
- imports: [
321
- NgxLinkifyjsModule.forRoot({
319
+ export const appConfig: ApplicationConfig = {
320
+ providers: [
321
+ provideNgxLinkifyjs({
322
322
  enableHash: false, // Disable hashtags
323
323
  enableMention: false // Disable mentions
324
324
  })
325
325
  ]
326
- })
327
- export class AppModule { }
326
+ };
328
327
  ```
329
328
 
330
329
  ---
@@ -452,7 +451,7 @@ When testing components that use ngx-linkifyjs:
452
451
 
453
452
  ```typescript
454
453
  import { ComponentFixture, TestBed } from '@angular/core/testing';
455
- import { NgxLinkifyjsPipe, NgxLinkifyjsService } from 'ngx-linkifyjs';
454
+ import { NgxLinkifyjsPipe, NgxLinkifyjsService } from '@code-name-jack/ngx-linkifyjs';
456
455
 
457
456
  describe('MyComponent', () => {
458
457
  let component: MyComponent;
@@ -486,8 +485,8 @@ describe('MyComponent', () => {
486
485
  ### Exports
487
486
 
488
487
  ```typescript
489
- // Module
490
- export { NgxLinkifyjsModule }
488
+ // Provider function (for both standalone and NgModule apps)
489
+ export { provideNgxLinkifyjs }
491
490
 
492
491
  // Standalone pipe
493
492
  export { NgxLinkifyjsPipe }
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { Pipe, Injectable, InjectionToken, NgModule } from '@angular/core';
2
+ import { Pipe, Injectable, InjectionToken, makeEnvironmentProviders } from '@angular/core';
3
3
  import linkifyStr from 'linkify-string';
4
4
  import * as linkify from 'linkifyjs';
5
5
 
@@ -13,7 +13,10 @@ var LinkType;
13
13
 
14
14
  class NgxLinkifyjsPipe {
15
15
  transform(value, options) {
16
- return value ? linkifyStr(value, options) : value;
16
+ if (!value) {
17
+ return '';
18
+ }
19
+ return linkifyStr(value, options);
17
20
  }
18
21
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe }); }
19
22
  static { this.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsPipe, isStandalone: true, name: "linkify" }); }
@@ -27,83 +30,119 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
27
30
  }] });
28
31
 
29
32
  class NgxLinkifyjsService {
30
- constructor() {
31
- }
32
33
  /**
33
34
  * Convert the passed text as a string to an appropriate url
34
35
  *
35
36
  * @param text - the string to convert
36
37
  * @param options - options to pass it to the linkifyjs library
38
+ * @returns HTML string with linkified URLs, emails, hashtags, and mentions
37
39
  */
38
40
  linkify(text, options) {
41
+ if (!text) {
42
+ return '';
43
+ }
39
44
  return linkifyStr(text, options);
40
45
  }
41
46
  /**
42
47
  * Find any links in a given text as a string
43
48
  *
44
49
  * @param text - the string to find some links
50
+ * @returns Array of Link objects found in the text
45
51
  */
46
52
  find(text) {
53
+ if (!text) {
54
+ return [];
55
+ }
47
56
  return linkify.find(text);
48
57
  }
49
58
  /**
50
59
  * Test if a given value is a link or an array of all links
51
60
  *
52
- * @param value - the value to test
61
+ * @param value - the value to test (string or array of strings)
62
+ * @returns true if all values are valid links, false otherwise
53
63
  */
54
64
  test(value) {
55
65
  if (typeof value === 'string') {
56
66
  return linkify.test(value);
57
67
  }
58
- return value.find(v => !linkify.test(v)) === undefined;
68
+ return value.every(v => linkify.test(v));
59
69
  }
60
70
  static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsService, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
61
- static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsService }); }
71
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsService, providedIn: 'root' }); }
62
72
  }
63
73
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsService, decorators: [{
64
- type: Injectable
65
- }], ctorParameters: () => [] });
74
+ type: Injectable,
75
+ args: [{ providedIn: 'root' }]
76
+ }] });
66
77
 
78
+ /**
79
+ * Injection token for NgxLinkifyjs configuration
80
+ */
67
81
  const NgxLinkifyjsConfigToken = new InjectionToken('NgxLinkifyjsConfig');
82
+ /**
83
+ * Default configuration for NgxLinkifyjs
84
+ */
68
85
  const DEFAULT_CONFIG = { enableHash: true, enableMention: true };
86
+
69
87
  // Conditionally import plugins based on configuration
70
88
  let pluginsLoaded = false;
71
89
  function loadPlugins(config) {
72
- if (pluginsLoaded)
90
+ if (pluginsLoaded) {
73
91
  return;
92
+ }
93
+ const pluginPromises = [];
74
94
  if (config?.enableHash) {
75
- import('linkify-plugin-hashtag').catch(err => console.error('Failed to load hashtag plugin:', err));
95
+ pluginPromises.push(import('linkify-plugin-hashtag').catch(err => {
96
+ console.error('Failed to load hashtag plugin:', err);
97
+ return null;
98
+ }));
76
99
  }
77
100
  if (config?.enableMention) {
78
- import('linkify-plugin-mention').catch(err => console.error('Failed to load mention plugin:', err));
101
+ pluginPromises.push(import('linkify-plugin-mention').catch(err => {
102
+ console.error('Failed to load mention plugin:', err);
103
+ return null;
104
+ }));
79
105
  }
80
- pluginsLoaded = true;
81
- }
82
- class NgxLinkifyjsModule {
83
- static forRoot(config = DEFAULT_CONFIG) {
84
- loadPlugins(config);
85
- return {
86
- ngModule: NgxLinkifyjsModule,
87
- providers: [
88
- NgxLinkifyjsService,
89
- {
90
- provide: NgxLinkifyjsConfigToken,
91
- useValue: config
92
- }
93
- ]
94
- };
106
+ if (pluginPromises.length > 0) {
107
+ Promise.all(pluginPromises).finally(() => {
108
+ pluginsLoaded = true;
109
+ });
110
+ }
111
+ else {
112
+ pluginsLoaded = true;
95
113
  }
96
- static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
97
- static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsModule, imports: [NgxLinkifyjsPipe], exports: [NgxLinkifyjsPipe] }); }
98
- static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsModule }); }
99
114
  }
100
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImport: i0, type: NgxLinkifyjsModule, decorators: [{
101
- type: NgModule,
102
- args: [{
103
- imports: [NgxLinkifyjsPipe],
104
- exports: [NgxLinkifyjsPipe]
105
- }]
106
- }] });
115
+ /**
116
+ * Provides NgxLinkifyjs services and configuration.
117
+ * Works with both standalone and NgModule-based applications.
118
+ *
119
+ * @param config - Configuration options for enabling hashtag and mention plugins
120
+ * @returns EnvironmentProviders array that can be used in app.config.ts
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * import { provideNgxLinkifyjs } from 'ngx-linkifyjs';
125
+ *
126
+ * export const appConfig: ApplicationConfig = {
127
+ * providers: [
128
+ * provideNgxLinkifyjs({
129
+ * enableHash: true,
130
+ * enableMention: true
131
+ * })
132
+ * ]
133
+ * };
134
+ * ```
135
+ */
136
+ function provideNgxLinkifyjs(config = DEFAULT_CONFIG) {
137
+ loadPlugins(config);
138
+ return makeEnvironmentProviders([
139
+ NgxLinkifyjsService,
140
+ {
141
+ provide: NgxLinkifyjsConfigToken,
142
+ useValue: { ...DEFAULT_CONFIG, ...config }
143
+ }
144
+ ]);
145
+ }
107
146
 
108
147
  /*
109
148
  * Public API Surface of ngx-linkifyjs
@@ -113,5 +152,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "20.3.9", ngImpor
113
152
  * Generated bundle index. Do not edit.
114
153
  */
115
154
 
116
- export { DEFAULT_CONFIG, LinkType, NgxLinkifyjsConfigToken, NgxLinkifyjsModule, NgxLinkifyjsPipe, NgxLinkifyjsService };
155
+ export { DEFAULT_CONFIG, LinkType, NgxLinkifyjsConfigToken, NgxLinkifyjsPipe, NgxLinkifyjsService, provideNgxLinkifyjs };
117
156
  //# sourceMappingURL=code-name-jack-ngx-linkifyjs.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"code-name-jack-ngx-linkifyjs.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/code-name-jack-ngx-linkifyjs.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: true\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 {InjectionToken, ModuleWithProviders, NgModule} from '@angular/core';\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// Conditionally import plugins based on configuration\nlet pluginsLoaded = false;\n\nfunction loadPlugins(config: NgxLinkifyjsConfig) {\n if (pluginsLoaded) return;\n \n if (config?.enableHash) {\n import('linkify-plugin-hashtag').catch(err => console.error('Failed to load hashtag plugin:', err));\n }\n\n if (config?.enableMention) {\n import('linkify-plugin-mention').catch(err => console.error('Failed to load mention plugin:', err));\n }\n \n pluginsLoaded = true;\n}\n\n@NgModule({\n imports: [NgxLinkifyjsPipe],\n exports: [NgxLinkifyjsPipe]\n})\nexport class NgxLinkifyjsModule {\n\n static forRoot(config: NgxLinkifyjsConfig = DEFAULT_CONFIG): ModuleWithProviders<NgxLinkifyjsModule> {\n loadPlugins(config);\n \n return {\n ngModule: NgxLinkifyjsModule,\n providers: [\n NgxLinkifyjsService,\n {\n provide: NgxLinkifyjsConfigToken,\n useValue: config\n }\n ]\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,GAAA,EAAA,CAAA,CAAA;;MCQP,gBAAgB,CAAA;IAE3B,SAAS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C,gBAAgB,CAAC;oBAC3B,OAAO,EAAE,CAAC,gBAAgB;AAC3B,iBAAA;;;ACrCD;;AAEG;;ACFH;;AAEG;;;;"}
1
+ {"version":3,"file":"code-name-jack-ngx-linkifyjs.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/constants/ngx-linkifyjs.constants.ts","../../../projects/ngx-linkifyjs-v2/src/lib/providers/ngx-linkifyjs.provider.ts","../../../projects/ngx-linkifyjs-v2/src/public-api.ts","../../../projects/ngx-linkifyjs-v2/src/code-name-jack-ngx-linkifyjs.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: true\n})\nexport class NgxLinkifyjsPipe implements PipeTransform {\n transform(value: string | null | undefined, options?: NgxLinkifyOptions): string {\n if (!value) {\n return '';\n }\n return linkifyStr(value, options);\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({ providedIn: 'root' })\nexport class NgxLinkifyjsService {\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 * @returns HTML string with linkified URLs, emails, hashtags, and mentions\n */\n linkify(text: string, options?: NgxLinkifyOptions): string {\n if (!text) {\n return '';\n }\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 * @returns Array of Link objects found in the text\n */\n find(text: string): Link[] {\n if (!text) {\n return [];\n }\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 (string or array of strings)\n * @returns true if all values are valid links, false otherwise\n */\n test(value: string | readonly string[]): boolean {\n if (typeof value === 'string') {\n return linkify.test(value);\n }\n return value.every(v => linkify.test(v));\n }\n}\n","import { InjectionToken } from '@angular/core';\nimport { NgxLinkifyjsConfig } from '../interfaces/ngx-linkifyjs.interface';\n\n/**\n * Injection token for NgxLinkifyjs configuration\n */\nexport const NgxLinkifyjsConfigToken = new InjectionToken<NgxLinkifyjsConfig>('NgxLinkifyjsConfig');\n\n/**\n * Default configuration for NgxLinkifyjs\n */\nexport const DEFAULT_CONFIG: NgxLinkifyjsConfig = { enableHash: true, enableMention: true };\n\n","import { EnvironmentProviders, makeEnvironmentProviders } from '@angular/core';\nimport { NgxLinkifyjsService } from '../service/ngx-linkifyjs.service';\nimport { NgxLinkifyjsConfig } from '../interfaces/ngx-linkifyjs.interface';\nimport { NgxLinkifyjsConfigToken, DEFAULT_CONFIG } from '../constants/ngx-linkifyjs.constants';\n\n// Conditionally import plugins based on configuration\nlet pluginsLoaded = false;\n\nfunction loadPlugins(config: NgxLinkifyjsConfig): void {\n if (pluginsLoaded) {\n return;\n }\n \n const pluginPromises: Promise<unknown>[] = [];\n\n if (config?.enableHash) {\n pluginPromises.push(\n import('linkify-plugin-hashtag').catch(err => {\n console.error('Failed to load hashtag plugin:', err);\n return null;\n })\n );\n }\n\n if (config?.enableMention) {\n pluginPromises.push(\n import('linkify-plugin-mention').catch(err => {\n console.error('Failed to load mention plugin:', err);\n return null;\n })\n );\n }\n\n if (pluginPromises.length > 0) {\n Promise.all(pluginPromises).finally(() => {\n pluginsLoaded = true;\n });\n } else {\n pluginsLoaded = true;\n }\n}\n\n/**\n * Provides NgxLinkifyjs services and configuration.\n * Works with both standalone and NgModule-based applications.\n * \n * @param config - Configuration options for enabling hashtag and mention plugins\n * @returns EnvironmentProviders array that can be used in app.config.ts\n * \n * @example\n * ```typescript\n * import { provideNgxLinkifyjs } from 'ngx-linkifyjs';\n * \n * export const appConfig: ApplicationConfig = {\n * providers: [\n * provideNgxLinkifyjs({\n * enableHash: true,\n * enableMention: true\n * })\n * ]\n * };\n * ```\n */\nexport function provideNgxLinkifyjs(\n config: NgxLinkifyjsConfig = DEFAULT_CONFIG\n): EnvironmentProviders {\n loadPlugins(config);\n \n return makeEnvironmentProviders([\n NgxLinkifyjsService,\n {\n provide: NgxLinkifyjsConfigToken,\n useValue: { ...DEFAULT_CONFIG, ...config }\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/providers/ngx-linkifyjs.provider';\nexport * from './lib/constants/ngx-linkifyjs.constants';\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,GAAA,EAAA,CAAA,CAAA;;MCQP,gBAAgB,CAAA;IAC3B,SAAS,CAAC,KAAgC,EAAE,OAA2B,EAAA;QACrE,IAAI,CAAC,KAAK,EAAE;AACV,YAAA,OAAO,EAAE;QACX;AACA,QAAA,OAAO,UAAU,CAAC,KAAK,EAAE,OAAO,CAAC;IACnC;8GANW,gBAAgB,EAAA,IAAA,EAAA,EAAA,EAAA,MAAA,EAAA,EAAA,CAAA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BAAmB;AACnB,QAAA;AACE,YAAA,OAAO,EAAE,uBAAuB;AAChC,YAAA,QAAQ,EAAE,EAAE,GAAG,cAAc,EAAE,GAAG,MAAM;AACzC;AACF,KAAA,CAAC;AACJ;;AC3EA;;AAEG;;ACFH;;AAEG;;;;"}
package/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as i0 from '@angular/core';
2
- import { PipeTransform, InjectionToken, ModuleWithProviders } from '@angular/core';
2
+ import { PipeTransform, EnvironmentProviders, InjectionToken } from '@angular/core';
3
3
 
4
4
  declare enum LinkType {
5
5
  URL = "url",
@@ -18,60 +18,85 @@ interface NgxLinkifyjsConfig {
18
18
  enableMention?: boolean;
19
19
  }
20
20
  interface NgxLinkifyOptions {
21
- attributes?: any;
21
+ attributes?: Record<string, string | number | boolean>;
22
22
  className?: string;
23
23
  defaultProtocol?: string;
24
- events?: any;
25
- ignoreTags?: Array<any>;
24
+ events?: Record<string, (event: Event) => void>;
25
+ ignoreTags?: string[];
26
26
  nl2br?: boolean;
27
27
  tagName?: string;
28
28
  target?: {
29
29
  url: string;
30
30
  };
31
31
  validate?: boolean;
32
- format?(value: any, type: any): any;
33
- formatHref?(href: any, type: any): any;
32
+ format?: (value: string, type: string) => string;
33
+ formatHref?: (href: string, type: string) => string;
34
34
  }
35
35
 
36
36
  declare class NgxLinkifyjsPipe implements PipeTransform {
37
- transform(value: string, options?: NgxLinkifyOptions): string;
37
+ transform(value: string | null | undefined, options?: NgxLinkifyOptions): string;
38
38
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxLinkifyjsPipe, never>;
39
39
  static ɵpipe: i0.ɵɵPipeDeclaration<NgxLinkifyjsPipe, "linkify", true>;
40
40
  }
41
41
 
42
42
  declare class NgxLinkifyjsService {
43
- constructor();
44
43
  /**
45
44
  * Convert the passed text as a string to an appropriate url
46
45
  *
47
46
  * @param text - the string to convert
48
47
  * @param options - options to pass it to the linkifyjs library
48
+ * @returns HTML string with linkified URLs, emails, hashtags, and mentions
49
49
  */
50
50
  linkify(text: string, options?: NgxLinkifyOptions): string;
51
51
  /**
52
52
  * Find any links in a given text as a string
53
53
  *
54
54
  * @param text - the string to find some links
55
+ * @returns Array of Link objects found in the text
55
56
  */
56
- find(text: string): Array<Link>;
57
+ find(text: string): Link[];
57
58
  /**
58
59
  * Test if a given value is a link or an array of all links
59
60
  *
60
- * @param value - the value to test
61
+ * @param value - the value to test (string or array of strings)
62
+ * @returns true if all values are valid links, false otherwise
61
63
  */
62
- test(value: string | string[]): boolean;
64
+ test(value: string | readonly string[]): boolean;
63
65
  static ɵfac: i0.ɵɵFactoryDeclaration<NgxLinkifyjsService, never>;
64
66
  static ɵprov: i0.ɵɵInjectableDeclaration<NgxLinkifyjsService>;
65
67
  }
66
68
 
69
+ /**
70
+ * Provides NgxLinkifyjs services and configuration.
71
+ * Works with both standalone and NgModule-based applications.
72
+ *
73
+ * @param config - Configuration options for enabling hashtag and mention plugins
74
+ * @returns EnvironmentProviders array that can be used in app.config.ts
75
+ *
76
+ * @example
77
+ * ```typescript
78
+ * import { provideNgxLinkifyjs } from 'ngx-linkifyjs';
79
+ *
80
+ * export const appConfig: ApplicationConfig = {
81
+ * providers: [
82
+ * provideNgxLinkifyjs({
83
+ * enableHash: true,
84
+ * enableMention: true
85
+ * })
86
+ * ]
87
+ * };
88
+ * ```
89
+ */
90
+ declare function provideNgxLinkifyjs(config?: NgxLinkifyjsConfig): EnvironmentProviders;
91
+
92
+ /**
93
+ * Injection token for NgxLinkifyjs configuration
94
+ */
67
95
  declare const NgxLinkifyjsConfigToken: InjectionToken<NgxLinkifyjsConfig>;
96
+ /**
97
+ * Default configuration for NgxLinkifyjs
98
+ */
68
99
  declare const DEFAULT_CONFIG: NgxLinkifyjsConfig;
69
- declare class NgxLinkifyjsModule {
70
- static forRoot(config?: NgxLinkifyjsConfig): ModuleWithProviders<NgxLinkifyjsModule>;
71
- static ɵfac: i0.ɵɵFactoryDeclaration<NgxLinkifyjsModule, never>;
72
- static ɵmod: i0.ɵɵNgModuleDeclaration<NgxLinkifyjsModule, never, [typeof NgxLinkifyjsPipe], [typeof NgxLinkifyjsPipe]>;
73
- static ɵinj: i0.ɵɵInjectorDeclaration<NgxLinkifyjsModule>;
74
- }
75
100
 
76
- export { DEFAULT_CONFIG, LinkType, NgxLinkifyjsConfigToken, NgxLinkifyjsModule, NgxLinkifyjsPipe, NgxLinkifyjsService };
101
+ export { DEFAULT_CONFIG, LinkType, NgxLinkifyjsConfigToken, NgxLinkifyjsPipe, NgxLinkifyjsService, provideNgxLinkifyjs };
77
102
  export type { Link, NgxLinkifyOptions, NgxLinkifyjsConfig };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@code-name-jack/ngx-linkifyjs",
3
3
  "description": "Angular wrapper for linkifyjs(v4) - library for finding links in plain text and converting them to HTML &lt;a&gt; tags via linkifyjs",
4
- "version": "20.0.2",
4
+ "version": "20.2.0",
5
5
  "homepage": "https://github.com/code-name-jack/ngx-linkifyjs-v2",
6
6
  "author": {
7
7
  "name": "Code Name Jack",
@@ -0,0 +1,10 @@
1
+ {
2
+ "$schema": "~node_modules/@angular-devkit/schematics/collection-schema.json",
3
+ "schematics": {
4
+ "ng-add": {
5
+ "description": "Installs @code-name-jack/ngx-linkifyjs package",
6
+ "factory": "./ng-add/index#ngAdd",
7
+ "schema": "./ng-add/schema.json"
8
+ }
9
+ }
10
+ }
@@ -0,0 +1,10 @@
1
+ import { Tree } from '@angular-devkit/schematics';
2
+ import { NodeDependency, NodeDependencyType } from '@schematics/angular/utility/dependencies';
3
+ /**
4
+ * Simplified dependency helper for Angular 20
5
+ */
6
+ /**
7
+ * Add a dependency to package.json
8
+ */
9
+ export declare function addPackageJsonDependency(host: Tree, dependency: NodeDependency): void;
10
+ export { NodeDependency, NodeDependencyType };
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.NodeDependencyType = void 0;
4
+ exports.addPackageJsonDependency = addPackageJsonDependency;
5
+ const dependencies_1 = require("@schematics/angular/utility/dependencies");
6
+ Object.defineProperty(exports, "NodeDependencyType", { enumerable: true, get: function () { return dependencies_1.NodeDependencyType; } });
7
+ /**
8
+ * Simplified dependency helper for Angular 20
9
+ */
10
+ /**
11
+ * Add a dependency to package.json
12
+ */
13
+ function addPackageJsonDependency(host, dependency) {
14
+ (0, dependencies_1.addPackageJsonDependency)(host, dependency);
15
+ }
16
+ //# sourceMappingURL=dependencies.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.js","sourceRoot":"","sources":["../../../../projects/ngx-linkifyjs-v2/schematics/helpers/dependencies.ts"],"names":[],"mappings":";;;AAcA,4DAKC;AAlBD,2EAIkD;AAgBzB,mGAjBvB,iCAAkB,OAiBuB;AAd3C;;GAEG;AAEH;;GAEG;AACH,SAAgB,wBAAwB,CACtC,IAAU,EACV,UAA0B;IAE1B,IAAA,uCAAa,EAAC,IAAI,EAAE,UAAU,CAAC,CAAC;AAClC,CAAC"}
@@ -0,0 +1 @@
1
+ export * from './dependencies';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./dependencies"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-linkifyjs-v2/schematics/helpers/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B"}
@@ -0,0 +1,8 @@
1
+ import { Rule } from '@angular-devkit/schematics';
2
+ /**
3
+ * Schematic factory for ng-add
4
+ * Installs @code-name-jack/ngx-linkifyjs package
5
+ */
6
+ export declare function ngAdd(options?: {
7
+ skipInstall?: boolean;
8
+ }): Rule;
@@ -0,0 +1,57 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ngAdd = ngAdd;
4
+ const schematics_1 = require("@angular-devkit/schematics");
5
+ const tasks_1 = require("@angular-devkit/schematics/tasks");
6
+ const helpers_1 = require("../helpers");
7
+ /**
8
+ * Schematic factory for ng-add
9
+ * Installs @code-name-jack/ngx-linkifyjs package
10
+ */
11
+ function ngAdd(options = {}) {
12
+ return (0, schematics_1.chain)([
13
+ addPackageJsonDependencies(),
14
+ options.skipInstall ? (0, schematics_1.noop)() : installPackageJsonDependencies(),
15
+ ]);
16
+ }
17
+ /**
18
+ * Adds package.json dependencies
19
+ */
20
+ function addPackageJsonDependencies() {
21
+ return (host, context) => {
22
+ const packageName = '@code-name-jack/ngx-linkifyjs';
23
+ const packageVersion = loadPackageVersion(context);
24
+ (0, helpers_1.addPackageJsonDependency)(host, {
25
+ type: helpers_1.NodeDependencyType.Default,
26
+ name: packageName,
27
+ version: packageVersion,
28
+ });
29
+ context.logger.info(`✅ Added "${packageName}" to dependencies`);
30
+ return host;
31
+ };
32
+ }
33
+ /**
34
+ * Installs package.json dependencies
35
+ */
36
+ function installPackageJsonDependencies() {
37
+ return (host, context) => {
38
+ context.addTask(new tasks_1.NodePackageInstallTask());
39
+ context.logger.info('📦 Installing packages...');
40
+ return host;
41
+ };
42
+ }
43
+ /**
44
+ * Loads package version from package.json
45
+ */
46
+ function loadPackageVersion(context) {
47
+ try {
48
+ // Try to get version from package.json in the schematic package
49
+ const packageJson = require('../../package.json');
50
+ return `^${packageJson.version}` || 'latest';
51
+ }
52
+ catch (_a) {
53
+ context.logger.warn('Could not determine package version, using "latest"');
54
+ return 'latest';
55
+ }
56
+ }
57
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../projects/ngx-linkifyjs-v2/schematics/ng-add/index.ts"],"names":[],"mappings":";;AAcA,sBAKC;AAnBD,2DAMoC;AACpC,4DAA0E;AAC1E,wCAA0E;AAE1E;;;GAGG;AACH,SAAgB,KAAK,CAAC,UAAqC,EAAE;IAC3D,OAAO,IAAA,kBAAK,EAAC;QACX,0BAA0B,EAAE;QAC5B,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,IAAA,iBAAI,GAAE,CAAC,CAAC,CAAC,8BAA8B,EAAE;KAChE,CAAC,CAAC;AACL,CAAC;AAED;;GAEG;AACH,SAAS,0BAA0B;IACjC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,MAAM,WAAW,GAAG,+BAA+B,CAAC;QACpD,MAAM,cAAc,GAAG,kBAAkB,CAAC,OAAO,CAAC,CAAC;QAEnD,IAAA,kCAAwB,EAAC,IAAI,EAAE;YAC7B,IAAI,EAAE,4BAAkB,CAAC,OAAO;YAChC,IAAI,EAAE,WAAW;YACjB,OAAO,EAAE,cAAc;SACxB,CAAC,CAAC;QAEH,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,WAAW,mBAAmB,CAAC,CAAC;QAEhE,OAAO,IAAI,CAAC;IACd,CAAC,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,SAAS,8BAA8B;IACrC,OAAO,CAAC,IAAU,EAAE,OAAyB,EAAE,EAAE;QAC/C,OAAO,CAAC,OAAO,CAAC,IAAI,8BAAsB,EAAE,CAAC,CAAC;QAC9C,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAC;QACjD,OAAO,I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