From d3a05d413d6beb34afbbc0a2b9faa7bea1f68c15 Mon Sep 17 00:00:00 2001 From: Stefan Plociennik <stefan.plociennik@mni.thm.de> Date: Sat, 15 May 2021 12:27:04 +0200 Subject: [PATCH] added back old way of highlighting keyword --- .../topic-dialog-comment.component.html | 19 +------------------ .../topic-dialog-comment.component.scss | 6 +----- .../topic-dialog-comment.component.ts | 13 +++++++++---- 3 files changed, 11 insertions(+), 27 deletions(-) diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html index f89f480d2..ef9738a6a 100644 --- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html +++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.html @@ -1,23 +1,6 @@ -<!-- working --> -<!-- <div> - <p> - <span *ngFor="let part Of partsOfQuestion; let i = index">{{part}}<mark *ngIf="i < partsOfQuestion.length -1">{{keyword}}</mark></span> - <button - *ngIf = "question.length > maxShowedCharachters" - (click)="isCollapsed = !isCollapsed"> - {{"dialog-comment.read-" + (!isCollapsed ? 'more': 'less') | translate}} - </button> - </p> -</div> --> - -<!-- WIP --> <div> <p> - <span *ngFor="let part Of partsOfQuestion"> - <span *ngIf="!part.toLowerCase().includes(keyword.toLowerCase()) && (!badWords.includes(part.toLowerCase()) || !profanityFilter)"> {{part}} </span> - <mark class="mark" *ngIf="part.toLowerCase().includes(keyword.toLowerCase())">{{part}}</mark> - <mark class="profanity" *ngIf="(badWords.includes(part.toLowerCase()) && profanityFilter)">{{part}}</mark> - </span> + <span *ngFor="let part Of partsOfQuestion; let i = index">{{part}}<mark *ngIf="i < partsOfQuestion.length -1">{{keyword}}</mark></span> <button *ngIf = "question.length > maxShowedCharachters" (click)="isCollapsed = !isCollapsed"> diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.scss b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.scss index 708520471..84e156146 100644 --- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.scss +++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.scss @@ -30,12 +30,8 @@ span { padding-left: 0px; } -.mark { +mark { background: none; color: var(--primary); } -.profanity { - background-color: black; - color: black; -} diff --git a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts index 2777191bd..8c953195f 100644 --- a/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts +++ b/src/app/components/shared/dialog/topic-dialog-comment/topic-dialog-comment.component.ts @@ -23,10 +23,15 @@ export class TopicDialogCommentComponent implements OnInit { constructor(private topicCloudAdminService: TopicCloudAdminService) { } get partsOfQuestion() { - const q = this.profanityFilter ? this.questionWithProfinity.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) : - this.question.slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters); - const q2 = q.split(' '); - return q2; + if (this.profanityFilter) { + return this.questionWithProfinity + .slice(0,this.isCollapsed? this.questionWithProfinity.length: this.maxShowedCharachters) + .split(new RegExp(this.keyword,'i')); + } else { + return this.question + .slice(0,this.isCollapsed? this.question.length: this.maxShowedCharachters) + .split(new RegExp(this.keyword,'i')); + } } ngOnInit(): void { -- GitLab