From d68ebf0b4a40f88e53a78de6b3109a41466fa7c6 Mon Sep 17 00:00:00 2001 From: Lesterpig Date: Wed, 2 Oct 2019 21:17:10 +0200 Subject: Add hyperlink video timestamps in description Fix #1312 (duplicates: #1728 and #2007) The modification is also applied to comments and video editing. --- .../app/videos/+video-watch/comment/video-comment.component.ts | 9 +++++---- client/src/app/videos/+video-watch/video-watch.component.ts | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.ts b/client/src/app/videos/+video-watch/comment/video-comment.component.ts index 23ff20aad..d5e3ecc17 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.ts @@ -4,7 +4,7 @@ import { VideoCommentThreadTree } from '../../../../../../shared/models/videos/v import { AuthService } from '../../../core/auth' import { Video } from '../../../shared/video/video.model' import { VideoComment } from './video-comment.model' -import { MarkdownService } from '@app/shared/renderer' +import { HtmlRendererService, MarkdownService } from '@app/shared/renderer' @Component({ selector: 'my-video-comment', @@ -28,6 +28,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { newParentComments: VideoComment[] = [] constructor ( + private htmlRenderer: HtmlRendererService, private markdownService: MarkdownService, private authService: AuthService ) {} @@ -78,7 +79,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { } isRemovableByUser () { - return this.comment.account && this.isUserLoggedIn() && + return this.isUserLoggedIn() && ( this.user.account.id === this.comment.account.id || this.user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) @@ -86,8 +87,8 @@ export class VideoCommentComponent implements OnInit, OnChanges { } private async init () { - this.sanitizedCommentHTML = await this.markdownService.textMarkdownToHTML(this.comment.text, true) - + const safeHTML = await this.htmlRenderer.toSafeHtml(this.comment.text) + this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(safeHTML) this.newParentComments = this.parentComments.concat([ this.comment ]) } } diff --git a/client/src/app/videos/+video-watch/video-watch.component.ts b/client/src/app/videos/+video-watch/video-watch.component.ts index 12b74a846..d9c88e972 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.ts +++ b/client/src/app/videos/+video-watch/video-watch.component.ts @@ -358,7 +358,8 @@ export class VideoWatchComponent implements OnInit, OnDestroy { } private async setVideoDescriptionHTML () { - this.videoHTMLDescription = await this.markdownService.textMarkdownToHTML(this.video.description) + const html = await this.markdownService.textMarkdownToHTML(this.video.description) + this.videoHTMLDescription = await this.markdownService.processVideoTimestamps(html) } private setVideoLikesBarTooltipText () { -- cgit v1.2.3