aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/+videos
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/+videos
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/+videos')
-rw-r--r--client/src/app/+videos/+video-edit/shared/video-edit.component.html2
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html27
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss14
-rw-r--r--client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts69
4 files changed, 40 insertions, 72 deletions
diff --git a/client/src/app/+videos/+video-edit/shared/video-edit.component.html b/client/src/app/+videos/+video-edit/shared/video-edit.component.html
index 579b63c6d..ea9909612 100644
--- a/client/src/app/+videos/+video-edit/shared/video-edit.component.html
+++ b/client/src/app/+videos/+video-edit/shared/video-edit.component.html
@@ -55,7 +55,7 @@
55 55
56 <my-markdown-textarea 56 <my-markdown-textarea
57 formControlName="description" [markdownVideo]="videoToUpdate" 57 formControlName="description" [markdownVideo]="videoToUpdate"
58 [formError]="formErrors.description" [truncate]="250" 58 [formError]="formErrors.description" [truncateTo3Lines]="true"
59 ></my-markdown-textarea> 59 ></my-markdown-textarea>
60 </div> 60 </div>
61 </div> 61 </div>
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html
index 9db3018e6..16f3e3881 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.html
@@ -1,25 +1,26 @@
1<div class="video-info-description"> 1<div class="video-info-description">
2 <div 2 <div
3 #descriptionHTML
3 class="video-info-description-html" 4 class="video-info-description-html"
4 [innerHTML]="getHTMLDescription()" 5 [ngClass]="{ 'ellipsis-multiline-3': !completeDescriptionShown }"
6 [innerHTML]="videoHTMLDescription"
5 (timestampClicked)="onTimestampClicked($event)" 7 (timestampClicked)="onTimestampClicked($event)"
6 myTimestampRouteTransformer 8 myTimestampRouteTransformer
7 ></div> 9 ></div>
8 10
9 <button 11 <button
10 *ngIf="completeDescriptionShown === false && video.description?.length >= 250" 12 *ngIf="(hasEllipsis() && !completeDescriptionShown) || completeDescriptionShown"
11 (click)="showMoreDescription()" class="video-info-description-more button-unstyle" 13 (click)="completeDescriptionShown = !completeDescriptionShown"
14 class="video-info-description-more button-unstyle"
12 > 15 >
13 <ng-container i18n>Show more</ng-container> 16 <ng-container *ngIf="!completeDescriptionShown">
14 <span *ngIf="descriptionLoading === false" class="chevron-down"></span> 17 <ng-container i18n>Show more</ng-container>
15 <my-loader size="sm" class="description-loading" [loading]="descriptionLoading"></my-loader> 18 <span class="chevron-down"></span>
16 </button> 19 </ng-container>
17 20
18 <button 21 <ng-container *ngIf="completeDescriptionShown">
19 *ngIf="completeDescriptionShown === true" 22 <ng-container i18n>Show less</ng-container>
20 (click)="showLessDescription()" class="video-info-description-more button-unstyle" 23 <span class="chevron-up"></span>
21 > 24 </ng-container>
22 <ng-container i18n>Show less</ng-container>
23 <span *ngIf="descriptionLoading === false" class="chevron-up"></span>
24 </button> 25 </button>
25</div> 26</div>
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss
index b503a94cb..d799ae2fc 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.scss
@@ -11,8 +11,14 @@
11 .video-info-description-html { 11 .video-info-description-html {
12 @include peertube-word-wrap; 12 @include peertube-word-wrap;
13 13
14 ::ng-deep a { 14 ::ng-deep {
15 text-decoration: none; 15 a {
16 text-decoration: none;
17 }
18
19 p:last-child {
20 margin-bottom: 0;
21 }
16 } 22 }
17 } 23 }
18 24
@@ -21,10 +27,12 @@
21 } 27 }
22 28
23 .video-info-description-more { 29 .video-info-description-more {
30 @include font-size(14px);
31
24 cursor: pointer; 32 cursor: pointer;
25 font-weight: $font-semibold; 33 font-weight: $font-semibold;
26 color: pvar(--greyForegroundColor); 34 color: pvar(--greyForegroundColor);
27 font-size: 14px; 35 margin-top: 1rem;
28 } 36 }
29} 37}
30 38
diff --git a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
index d01080611..911cf7264 100644
--- a/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
+++ b/client/src/app/+videos/+video-watch/shared/metadata/video-description.component.ts
@@ -1,7 +1,6 @@
1import { Component, EventEmitter, Input, OnChanges, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnChanges, Output, ViewChild, ElementRef } from '@angular/core'
2import { MarkdownService, Notifier } from '@app/core' 2import { MarkdownService } from '@app/core'
3import { VideoDetails, VideoService } from '@app/shared/shared-main' 3import { VideoDetails } from '@app/shared/shared-main'
4import { logger } from '@root-helpers/logger'
5 4
6@Component({ 5@Component({
7 selector: 'my-video-description', 6 selector: 'my-video-description',
@@ -9,36 +8,34 @@ import { logger } from '@root-helpers/logger'
9 styleUrls: [ './video-description.component.scss' ] 8 styleUrls: [ './video-description.component.scss' ]
10}) 9})
11export class VideoDescriptionComponent implements OnChanges { 10export class VideoDescriptionComponent implements OnChanges {
11 @ViewChild('descriptionHTML') descriptionHTML: ElementRef<HTMLElement>
12
12 @Input() video: VideoDetails 13 @Input() video: VideoDetails
13 14
14 @Output() timestampClicked = new EventEmitter<number>() 15 @Output() timestampClicked = new EventEmitter<number>()
15 16
16 descriptionLoading = false
17 completeDescriptionShown = false 17 completeDescriptionShown = false
18 18
19 completeVideoDescriptionLoaded = false
20
21 videoHTMLTruncatedDescription = ''
22 videoHTMLDescription = '' 19 videoHTMLDescription = ''
23 20
24 constructor ( 21 constructor (
25 private videoService: VideoService,
26 private notifier: Notifier,
27 private markdownService: MarkdownService 22 private markdownService: MarkdownService
28 ) { } 23 ) { }
29 24
30 ngOnChanges () { 25 ngOnChanges () {
31 this.descriptionLoading = false
32 this.completeDescriptionShown = false 26 this.completeDescriptionShown = false
33 27
34 this.setVideoDescriptionHTML() 28 this.setVideoDescriptionHTML()
35 } 29 }
36 30
37 showMoreDescription () { 31 hasEllipsis () {
38 if (!this.completeVideoDescriptionLoaded) { 32 const el = this.descriptionHTML?.nativeElement
39 return this.loadCompleteDescription() 33 if (!el) return false
40 } 34
35 return el.offsetHeight < el.scrollHeight
36 }
41 37
38 showMoreDescription () {
42 this.completeDescriptionShown = true 39 this.completeDescriptionShown = true
43 } 40 }
44 41
@@ -46,51 +43,13 @@ export class VideoDescriptionComponent implements OnChanges {
46 this.completeDescriptionShown = false 43 this.completeDescriptionShown = false
47 } 44 }
48 45
49 loadCompleteDescription () {
50 this.descriptionLoading = true
51
52 this.videoService.loadCompleteDescription(this.video.descriptionPath)
53 .subscribe({
54 next: description => {
55 this.completeDescriptionShown = true
56 this.descriptionLoading = false
57
58 this.video.description = description
59
60 this.setVideoDescriptionHTML()
61 .catch(err => logger.error(err))
62 },
63
64 error: err => {
65 this.descriptionLoading = false
66 this.notifier.error(err.message)
67 }
68 })
69 }
70
71 onTimestampClicked (timestamp: number) { 46 onTimestampClicked (timestamp: number) {
72 this.timestampClicked.emit(timestamp) 47 this.timestampClicked.emit(timestamp)
73 } 48 }
74 49
75 getHTMLDescription () {
76 if (this.completeDescriptionShown) {
77 return this.videoHTMLDescription
78 }
79
80 return this.videoHTMLTruncatedDescription
81 }
82
83 private async setVideoDescriptionHTML () { 50 private async setVideoDescriptionHTML () {
84 { 51 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description })
85 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.description })
86
87 this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
88 }
89
90 {
91 const html = await this.markdownService.textMarkdownToHTML({ markdown: this.video.truncatedDescription })
92 52
93 this.videoHTMLTruncatedDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html) 53 this.videoHTMLDescription = this.markdownService.processVideoTimestamps(this.video.shortUUID, html)
94 }
95 } 54 }
96} 55}