aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-08-17 14:26:49 +0200
committerChocobozzz <me@florianbigard.com>2023-08-17 14:34:49 +0200
commitc5f8dc0533153658f46b68a9e214646b41abebfc (patch)
tree7e2118845ac89cd2a07b35fa064d8e134c54ca75 /client/src/app/shared
parente4f82eaa8b5c47874f53b82bc6910f1f93189548 (diff)
downloadPeerTube-c5f8dc0533153658f46b68a9e214646b41abebfc.tar.gz
PeerTube-c5f8dc0533153658f46b68a9e214646b41abebfc.tar.zst
PeerTube-c5f8dc0533153658f46b68a9e214646b41abebfc.zip
Correctly truncate HTML
We can because we don't use the video truncated description since v5.0
Diffstat (limited to 'client/src/app/shared')
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-details.component.html2
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-list-table.component.html3
-rw-r--r--client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts7
-rw-r--r--client/src/app/shared/shared-abuse-list/processed-abuse.model.ts3
-rw-r--r--client/src/app/shared/shared-forms/markdown-textarea.component.html4
-rw-r--r--client/src/app/shared/shared-forms/markdown-textarea.component.ts5
6 files changed, 9 insertions, 15 deletions
diff --git a/client/src/app/shared/shared-abuse-list/abuse-details.component.html b/client/src/app/shared/shared-abuse-list/abuse-details.component.html
index 2d3e26a25..5a4e60fe7 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-details.component.html
+++ b/client/src/app/shared/shared-abuse-list/abuse-details.component.html
@@ -96,7 +96,7 @@
96 <strong i18n>Comment:</strong> 96 <strong i18n>Comment:</strong>
97 </div> 97 </div>
98 98
99 <div [innerHTML]="abuse.commentHtml"></div> 99 <div [innerHTML]="abuse.commentHTML"></div>
100 </div> 100 </div>
101 </div> 101 </div>
102</div> 102</div>
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
index 5833e3465..253237122 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.html
@@ -90,7 +90,8 @@
90 90
91 <ng-container *ngIf="abuse.comment"> 91 <ng-container *ngIf="abuse.comment">
92 <td> 92 <td>
93 <a [href]="getCommentUrl(abuse)" [innerHTML]="abuse.truncatedCommentHtml" class="table-comment-link" 93 <a
94 [href]="getCommentUrl(abuse)" [innerHTML]="abuse.commentHTML" class="table-comment-link ellipsis-multiline-1"
94 [title]="abuse.comment.video.name" target="_blank" rel="noopener noreferrer" 95 [title]="abuse.comment.video.name" target="_blank" rel="noopener noreferrer"
95 ></a> 96 ></a>
96 97
diff --git a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
index c38e1286f..691859584 100644
--- a/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
+++ b/client/src/app/shared/shared-abuse-list/abuse-list-table.component.ts
@@ -1,5 +1,4 @@
1import * as debug from 'debug' 1import * as debug from 'debug'
2import truncate from 'lodash-es/truncate'
3import { SortMeta } from 'primeng/api' 2import { SortMeta } from 'primeng/api'
4import { Component, Input, OnInit, ViewChild } from '@angular/core' 3import { Component, Input, OnInit, ViewChild } from '@angular/core'
5import { ActivatedRoute, Router } from '@angular/router' 4import { ActivatedRoute, Router } from '@angular/router'
@@ -211,11 +210,9 @@ export class AbuseListTableComponent extends RestTable implements OnInit {
211 210
212 if (abuse.comment) { 211 if (abuse.comment) {
213 if (abuse.comment.deleted) { 212 if (abuse.comment.deleted) {
214 abuse.truncatedCommentHtml = abuse.commentHtml = $localize`Deleted comment` 213 abuse.commentHTML = $localize`Deleted comment`
215 } else { 214 } else {
216 const truncated = truncate(abuse.comment.text, { length: 100 }) 215 abuse.commentHTML = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true })
217 abuse.truncatedCommentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: truncated, withHtml: true })
218 abuse.commentHtml = await this.markdownRenderer.textMarkdownToHTML({ markdown: abuse.comment.text, withHtml: true })
219 } 216 }
220 } 217 }
221 218
diff --git a/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts b/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts
index 076ccb40b..c51d6877e 100644
--- a/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts
+++ b/client/src/app/shared/shared-abuse-list/processed-abuse.model.ts
@@ -12,8 +12,7 @@ export type ProcessedAbuse = AdminAbuse & {
12 reporterAccount?: Account 12 reporterAccount?: Account
13 flaggedAccount?: Account 13 flaggedAccount?: Account
14 14
15 truncatedCommentHtml?: string 15 commentHTML?: string
16 commentHtml?: string
17 16
18 video: AdminAbuse['video'] & { 17 video: AdminAbuse['video'] & {
19 channel: AdminAbuse['video']['channel'] & { 18 channel: AdminAbuse['video']['channel'] & {
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.html b/client/src/app/shared/shared-forms/markdown-textarea.component.html
index 63dcdc597..ac2dfd17c 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.html
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.html
@@ -8,11 +8,11 @@
8 </textarea> 8 </textarea>
9 9
10 <div ngbNav #nav="ngbNav" class="nav-pills nav-preview"> 10 <div ngbNav #nav="ngbNav" class="nav-pills nav-preview">
11 <ng-container ngbNavItem *ngIf="truncate !== undefined"> 11 <ng-container ngbNavItem *ngIf="truncateTo3Lines">
12 <a ngbNavLink i18n>Truncated preview</a> 12 <a ngbNavLink i18n>Truncated preview</a>
13 13
14 <ng-template ngbNavContent> 14 <ng-template ngbNavContent>
15 <div [innerHTML]="truncatedPreviewHTML"></div> 15 <div class="ellipsis-multiline-3" [innerHTML]="previewHTML"></div>
16 </ng-template> 16 </ng-template>
17 </ng-container> 17 </ng-container>
18 18
diff --git a/client/src/app/shared/shared-forms/markdown-textarea.component.ts b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
index 7edcf868c..169be39d1 100644
--- a/client/src/app/shared/shared-forms/markdown-textarea.component.ts
+++ b/client/src/app/shared/shared-forms/markdown-textarea.component.ts
@@ -1,4 +1,3 @@
1import truncate from 'lodash-es/truncate'
2import { Subject } from 'rxjs' 1import { Subject } from 'rxjs'
3import { debounceTime, distinctUntilChanged } from 'rxjs/operators' 2import { debounceTime, distinctUntilChanged } from 'rxjs/operators'
4import { ViewportScroller } from '@angular/common' 3import { ViewportScroller } from '@angular/common'
@@ -26,7 +25,7 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
26 25
27 @Input() formError: string 26 @Input() formError: string
28 27
29 @Input() truncate: number 28 @Input() truncateTo3Lines: boolean
30 29
31 @Input() markdownType: 'text' | 'enhanced' | 'to-unsafe-html' = 'text' 30 @Input() markdownType: 'text' | 'enhanced' | 'to-unsafe-html' = 'text'
32 @Input() customMarkdownRenderer?: (text: string) => Promise<string | HTMLElement> 31 @Input() customMarkdownRenderer?: (text: string) => Promise<string | HTMLElement>
@@ -42,7 +41,6 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
42 @ViewChild('textarea') textareaElement: ElementRef 41 @ViewChild('textarea') textareaElement: ElementRef
43 @ViewChild('previewElement') previewElement: ElementRef 42 @ViewChild('previewElement') previewElement: ElementRef
44 43
45 truncatedPreviewHTML: SafeHtml | string = ''
46 previewHTML: SafeHtml | string = '' 44 previewHTML: SafeHtml | string = ''
47 45
48 isMaximized = false 46 isMaximized = false
@@ -129,7 +127,6 @@ export class MarkdownTextareaComponent implements ControlValueAccessor, OnInit {
129 private async updatePreviews () { 127 private async updatePreviews () {
130 if (this.content === null || this.content === undefined) return 128 if (this.content === null || this.content === undefined) return
131 129
132 this.truncatedPreviewHTML = await this.markdownRender(truncate(this.content, { length: this.truncate }))
133 this.previewHTML = await this.markdownRender(this.content) 130 this.previewHTML = await this.markdownRender(this.content)
134 } 131 }
135 132