From b29bf61dbd518e5cef0b2f564ddc8f8a0657d089 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Mon, 16 Dec 2019 16:21:42 +0100 Subject: Provide native links for description timestamps, and re-clickability for these --- .../+video-watch/comment/video-comment.component.html | 8 +++++++- .../videos/+video-watch/comment/video-comment.component.ts | 14 +++++++++----- .../+video-watch/comment/video-comments.component.html | 2 ++ .../+video-watch/comment/video-comments.component.ts | 8 +++++++- .../src/app/videos/+video-watch/video-watch.component.html | 14 ++++++++++++-- .../src/app/videos/+video-watch/video-watch.component.scss | 4 ++++ .../src/app/videos/+video-watch/video-watch.component.ts | 13 +++++++++++-- client/src/app/videos/+video-watch/video-watch.module.ts | 9 +++++++-- 8 files changed, 59 insertions(+), 13 deletions(-) (limited to 'client/src/app/videos') diff --git a/client/src/app/videos/+video-watch/comment/video-comment.component.html b/client/src/app/videos/+video-watch/comment/video-comment.component.html index 04bb1f7a2..df996533d 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comment.component.html @@ -23,7 +23,12 @@ {{ comment.createdAt | myFromNow }} -
+
Reply
@@ -65,6 +70,7 @@ (wantedToReply)="onWantToReply($event)" (wantedToDelete)="onWantToDelete($event)" (resetReply)="onResetReply()" + (timestampClicked)="handleTimestampClicked($event)" >
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 d5e3ecc17..b2bf3ee1b 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 { HtmlRendererService, MarkdownService } from '@app/shared/renderer' +import { MarkdownService } from '@app/shared/renderer' @Component({ selector: 'my-video-comment', @@ -23,12 +23,12 @@ export class VideoCommentComponent implements OnInit, OnChanges { @Output() wantedToReply = new EventEmitter() @Output() threadCreated = new EventEmitter() @Output() resetReply = new EventEmitter() + @Output() timestampClicked = new EventEmitter() sanitizedCommentHTML = '' newParentComments: VideoComment[] = [] constructor ( - private htmlRenderer: HtmlRendererService, private markdownService: MarkdownService, private authService: AuthService ) {} @@ -78,8 +78,12 @@ export class VideoCommentComponent implements OnInit, OnChanges { this.resetReply.emit() } + handleTimestampClicked (timestamp: number) { + this.timestampClicked.emit(timestamp) + } + isRemovableByUser () { - return this.isUserLoggedIn() && + return this.comment.account && this.isUserLoggedIn() && ( this.user.account.id === this.comment.account.id || this.user.hasRight(UserRight.REMOVE_ANY_VIDEO_COMMENT) @@ -87,8 +91,8 @@ export class VideoCommentComponent implements OnInit, OnChanges { } private async init () { - const safeHTML = await this.htmlRenderer.toSafeHtml(this.comment.text) - this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(safeHTML) + const html = await this.markdownService.textMarkdownToHTML(this.comment.text, true) + this.sanitizedCommentHTML = await this.markdownService.processVideoTimestamps(html) this.newParentComments = this.parentComments.concat([ this.comment ]) } } diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.html b/client/src/app/videos/+video-watch/comment/video-comments.component.html index 844263ddd..5fabb7dfe 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.html +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.html @@ -40,6 +40,7 @@ (wantedToDelete)="onWantedToDelete($event)" (threadCreated)="onThreadCreated($event)" (resetReply)="onResetReply()" + (timestampClicked)="handleTimestampClicked($event)" > @@ -54,6 +55,7 @@ (wantedToDelete)="onWantedToDelete($event)" (threadCreated)="onThreadCreated($event)" (resetReply)="onResetReply()" + (timestampClicked)="handleTimestampClicked($event)" >
diff --git a/client/src/app/videos/+video-watch/comment/video-comments.component.ts b/client/src/app/videos/+video-watch/comment/video-comments.component.ts index cc8b98b4e..e81401553 100644 --- a/client/src/app/videos/+video-watch/comment/video-comments.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comments.component.ts @@ -1,4 +1,4 @@ -import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild } from '@angular/core' +import { Component, ElementRef, Input, OnChanges, OnDestroy, OnInit, SimpleChanges, ViewChild, Output, EventEmitter } from '@angular/core' import { ActivatedRoute } from '@angular/router' import { ConfirmService, Notifier } from '@app/core' import { Subject, Subscription } from 'rxjs' @@ -24,6 +24,8 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { @Input() video: VideoDetails @Input() user: User + @Output() timestampClicked = new EventEmitter() + comments: VideoComment[] = [] highlightedThread: VideoComment sort: VideoSortField = '-createdAt' @@ -150,6 +152,10 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy { this.viewReplies(commentTree.comment.id) } + handleTimestampClicked (timestamp: number) { + this.timestampClicked.emit(timestamp) + } + async onWantedToDelete (commentToDelete: VideoComment) { let message = 'Do you really want to delete this comment?' diff --git a/client/src/app/videos/+video-watch/video-watch.component.html b/client/src/app/videos/+video-watch/video-watch.component.html index b3def01fa..77e0b9256 100644 --- a/client/src/app/videos/+video-watch/video-watch.component.html +++ b/client/src/app/videos/+video-watch/video-watch.component.html @@ -162,7 +162,12 @@
-
+
Show more @@ -223,7 +228,12 @@
- + { + this.queryParamsSub = this.route.queryParams.subscribe(async queryParams => { const videoId = queryParams[ 'videoId' ] - if (videoId) this.loadVideo(videoId) + if (videoId) await this.loadVideo(videoId) + + const start = queryParams[ 'start' ] + if (this.player && start) this.player.currentTime(parseInt(start, 10)) }) this.initHotkeys() @@ -284,6 +288,11 @@ export class VideoWatchComponent implements OnInit, OnDestroy { ) } + handleTimestampClicked (timestamp: number) { + if (this.player) this.player.currentTime(timestamp) + scrollToTop() + } + isPlaylistAutoPlayEnabled () { return ( (this.user && this.user.autoPlayNextVideoPlaylist) || diff --git a/client/src/app/videos/+video-watch/video-watch.module.ts b/client/src/app/videos/+video-watch/video-watch.module.ts index 2e45e5674..5fa50ecbb 100644 --- a/client/src/app/videos/+video-watch/video-watch.module.ts +++ b/client/src/app/videos/+video-watch/video-watch.module.ts @@ -13,6 +13,7 @@ import { RecommendationsModule } from '@app/videos/recommendations/recommendatio import { VideoWatchPlaylistComponent } from '@app/videos/+video-watch/video-watch-playlist.component' import { QRCodeModule } from 'angularx-qrcode' import { InputSwitchModule } from 'primeng/inputswitch' +import { TimestampRouteTransformerDirective } from '@app/shared/angular/timestamp-route-transformer.directive' @NgModule({ imports: [ @@ -32,11 +33,15 @@ import { InputSwitchModule } from 'primeng/inputswitch' VideoSupportComponent, VideoCommentsComponent, VideoCommentAddComponent, - VideoCommentComponent + VideoCommentComponent, + + TimestampRouteTransformerDirective ], exports: [ - VideoWatchComponent + VideoWatchComponent, + + TimestampRouteTransformerDirective ], providers: [ -- cgit v1.2.3