diff --git a/dashboard/divhelpcontent/div-help-contents.component.ts b/dashboard/divhelpcontent/div-help-contents.component.ts
index 55de77f2..964e9424 100644
--- a/dashboard/divhelpcontent/div-help-contents.component.ts
+++ b/dashboard/divhelpcontent/div-help-contents.component.ts
@@ -17,6 +17,7 @@ import {LoginErrorCodes} from '../../login/utils/guardHelper.class';
import {HelperFunctions} from "../../utils/HelperFunctions.class";
import {Subscriber} from "rxjs";
import {properties} from "../../../../environments/environment";
+import {StringUtils} from '../../utils/string-utils.class';
@Component({
selector: 'div-help-contents',
@@ -363,8 +364,7 @@ export class DivHelpContentsComponent implements OnInit {
}
public cutContent(divHelpContent: DivHelpContent) {
- divHelpContent.content = divHelpContent.content.replace(/<[^>]*>/g, '');
- divHelpContent.content = divHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
+ divHelpContent.content = StringUtils.HTMLToString(divHelpContent.content);
if (divHelpContent.content.length > 200) {
divHelpContent.content = divHelpContent.content.substr(0, 200) + "...";
}
diff --git a/dashboard/helpTexts/page-help-contents.component.html b/dashboard/helpTexts/page-help-contents.component.html
index 360144cd..559aa342 100644
--- a/dashboard/helpTexts/page-help-contents.component.html
+++ b/dashboard/helpTexts/page-help-contents.component.html
@@ -86,7 +86,8 @@
{{check.pageHelpContent.page.name}}
-
{{check.pageHelpContent.content}}
+
+
{{check.pageHelpContent.content|htmlToString}}
diff --git a/dashboard/helpTexts/page-help-contents.component.ts b/dashboard/helpTexts/page-help-contents.component.ts
index 37f8dffb..855288f7 100644
--- a/dashboard/helpTexts/page-help-contents.component.ts
+++ b/dashboard/helpTexts/page-help-contents.component.ts
@@ -187,7 +187,6 @@ export class PageHelpContentsComponent implements OnInit {
this.checkboxes = [];
for (let i = this.pageHelpContents.length - 1; i >= 0; i -= 1) {
- this.cutContent(this.pageHelpContents[i]);
this.checkboxes.unshift({
pageHelpContent: this.pageHelpContents[i],
checked: false
@@ -331,7 +330,6 @@ export class PageHelpContentsComponent implements OnInit {
}
public pageHelpContentSavedSuccessfully(pageHelpContent: PageHelpContent) {
- this.cutContent(pageHelpContent);
this.checkboxes.push({pageHelpContent: pageHelpContent, checked: false});
this.pageHelpContents.push(pageHelpContent);
this.applyCheck(false);
@@ -355,20 +353,11 @@ export class PageHelpContentsComponent implements OnInit {
return idFlag && activeFlag && textFlag;
}
- public cutContent(pageHelpContent: PageHelpContent) {
- pageHelpContent.content = pageHelpContent.content.replace(/<[^>]*>/g, '');
- pageHelpContent.content = pageHelpContent.content.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
-
- if (pageHelpContent.content.length > 200) {
- pageHelpContent.content = pageHelpContent.content.substr(0, 200) + "...";
- }
- }
public applyFilter() {
this.checkboxes = [];
this.pageHelpContents.filter(item => this.filterPageHelpContent(item, this.filters)).forEach(
_ => {
- this.cutContent(_);
this.checkboxes.push({pageHelpContent: _, checked: false})
}
);
diff --git a/dashboard/helpTexts/page-help-contents.module.ts b/dashboard/helpTexts/page-help-contents.module.ts
index 3a5fbb1d..30f04793 100644
--- a/dashboard/helpTexts/page-help-contents.module.ts
+++ b/dashboard/helpTexts/page-help-contents.module.ts
@@ -17,12 +17,13 @@ import {IconsModule} from '../../utils/icons/icons.module';
import {IconsService} from '../../utils/icons/icons.service';
import {add, arrow_left} from '../../utils/icons/icons';
import {LoadingModule} from '../../utils/loading/loading.module';
+import {HTMLToStringPipeModule} from '../../utils/pipes/HTMLToStringPipe.module';
@NgModule({
imports: [
CommonModule, RouterModule, FormsModule, SafeHtmlPipeModule,
AlertModalModule, ReactiveFormsModule, MatSlideToggleModule, AdminToolServiceModule, InputModule, PageHelpContentsRoutingModule, PageContentModule,
- SearchInputModule, IconsModule, LoadingModule
+ SearchInputModule, IconsModule, LoadingModule, HTMLToStringPipeModule
],
declarations: [
PageHelpContentsComponent
diff --git a/notifications/notification.service.ts b/notifications/notification.service.ts
index 28dc496e..e45e7e80 100644
--- a/notifications/notification.service.ts
+++ b/notifications/notification.service.ts
@@ -6,6 +6,7 @@ import {Notification, NotificationUser} from "./notifications";
import {CustomOptions} from "../services/servicesUtils/customOptions.class";
import {not} from "rxjs/internal-compatibility";
import {map} from "rxjs/operators";
+import {StringUtils} from '../utils/string-utils.class';
@Injectable({
providedIn: "root"
@@ -46,8 +47,7 @@ export class NotificationService {
if (notification.title) {
notification.preview = notification.title;
} else {
- notification.preview = notification.message.replace(/<[^>]*>/g, '');
- notification.preview = notification.preview.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
+ notification.preview = StringUtils.HTMLToString(notification.message);
}
return notification;
}
diff --git a/utils/pipes/HTMLToString.pipe.ts b/utils/pipes/HTMLToString.pipe.ts
new file mode 100644
index 00000000..615bcde8
--- /dev/null
+++ b/utils/pipes/HTMLToString.pipe.ts
@@ -0,0 +1,13 @@
+import {Pipe, PipeTransform} from '@angular/core';
+
+import {SafeUrl} from '@angular/platform-browser';
+import {StringUtils} from '../string-utils.class';
+
+@Pipe({ name: 'htmlToString'})
+export class HTMLToStringPipe implements PipeTransform {
+ constructor() {}
+
+ transform(value):SafeUrl {
+ return StringUtils.HTMLToString(value);
+ }
+}
diff --git a/utils/pipes/HTMLToStringPipe.module.ts b/utils/pipes/HTMLToStringPipe.module.ts
new file mode 100644
index 00000000..98dbe64b
--- /dev/null
+++ b/utils/pipes/HTMLToStringPipe.module.ts
@@ -0,0 +1,22 @@
+import { NgModule } from '@angular/core';
+import {HTMLToStringPipe} from './HTMLToString.pipe';
+
+
+
+@NgModule({
+ imports: [
+
+ ],
+ declarations: [
+ HTMLToStringPipe
+ ],
+ providers:[],
+ exports: [
+ HTMLToStringPipe
+ ]
+})
+
+
+export class HTMLToStringPipeModule{
+
+}
diff --git a/utils/string-utils.class.ts b/utils/string-utils.class.ts
index 0a14f05e..4b60b1c7 100644
--- a/utils/string-utils.class.ts
+++ b/utils/string-utils.class.ts
@@ -363,4 +363,14 @@ export class StringUtils {
}
return false;
}
+ public static HTMLToString( html:string){
+ try {
+ html = html.replace(/ /g, ' ');
+ html = html.replace(/(\r\n|\n|\r| +(?= ))|\s\s+/gm, " ");
+ html = html.replace(/<[^>]*>/g, '');
+ }catch( e){
+ }
+ console.log(html);
+ return html;
+ }
}