From d401ba49d07df62320d58dfaff5fdd65db2ab504 Mon Sep 17 00:00:00 2001 From: Thaisah van Vugt Date: Wed, 4 Sep 2019 15:17:17 +0200 Subject: [PATCH 1/3] V1 --- .../ngx-json-viewer.component.html | 4 ++-- src/ngx-json-viewer/ngx-json-viewer.component.ts | 15 ++++++++++++--- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/ngx-json-viewer/ngx-json-viewer.component.html b/src/ngx-json-viewer/ngx-json-viewer.component.html index 9f90328..0d9e2d7 100644 --- a/src/ngx-json-viewer/ngx-json-viewer.component.html +++ b/src/ngx-json-viewer/ngx-json-viewer.component.html @@ -12,10 +12,10 @@
{{ segment.key }} : - {{ segment.description }} +
- +
diff --git a/src/ngx-json-viewer/ngx-json-viewer.component.ts b/src/ngx-json-viewer/ngx-json-viewer.component.ts index 1005e40..36607fb 100644 --- a/src/ngx-json-viewer/ngx-json-viewer.component.ts +++ b/src/ngx-json-viewer/ngx-json-viewer.component.ts @@ -6,6 +6,7 @@ export interface Segment { type: undefined | string; description: string; expanded: boolean; + clickableLinks: boolean; } @Component({ @@ -17,6 +18,7 @@ export class NgxJsonViewerComponent implements OnChanges { @Input() json: any; @Input() expanded = true; + @Input() clickableLinks = false; /** * @deprecated It will be always true and deleted in version 3.0.0 */ @@ -54,8 +56,10 @@ export class NgxJsonViewerComponent implements OnChanges { value: value, type: undefined, description: '' + value, - expanded: this.expanded + expanded: this.expanded, + clickableLinks: this.clickableLinks }; + const htmlRegexp: any = /^(http:\/\/www\.|https:\/\/www\.|http:\/\/|https:\/\/)?[a-z0-9]+([\-\.]{1}[a-z0-9]+)*\.[a-z]{2,5}(:[0-9]{1,5})?(\/.*)?$/; switch (typeof segment.value) { case 'number': { @@ -71,8 +75,13 @@ export class NgxJsonViewerComponent implements OnChanges { break; } case 'string': { - segment.type = 'string'; - segment.description = '"' + segment.value + '"'; + if (segment.clickableLinks && htmlRegexp.test(segment.value)) { + segment.type = 'url'; + segment.description = '' + segment.value + ''; + } else { + segment.type = 'string'; + segment.description = '"' + segment.value + '"'; + } break; } case 'undefined': { From ae26a51ec15fb3a131033ee7c8bf0724d222a77b Mon Sep 17 00:00:00 2001 From: Thaisah van Vugt Date: Wed, 4 Sep 2019 15:21:33 +0200 Subject: [PATCH 2/3] Read Me --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index de70d8b..743cbee 100644 --- a/README.md +++ b/README.md @@ -41,3 +41,8 @@ To collapse all nodes at first: ```html ``` + +Makes URLs clickable +```html + +``` From 2ae7ff6a72b5fac4799f3e1f8eda90e4bec077c0 Mon Sep 17 00:00:00 2001 From: Thaisah van Vugt Date: Wed, 4 Sep 2019 15:53:20 +0200 Subject: [PATCH 3/3] version bumb --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 65075c5..35a6699 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "ngx-json-viewer", - "version": "2.4.0", + "version": "2.4.1", "description": "JSON formatter / viewer for Angular 2/4/5/6/7+", "keywords": [ "angular",