aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/shared/shared-forms
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/shared-forms
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/shared-forms')
-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
2 files changed, 3 insertions, 6 deletions
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