From 5de8a55abce53108bc1024f1194457c6528bd11e Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Feb 2018 10:41:11 +0100 Subject: Handle line feeds in comments --- .../src/app/videos/+video-watch/comment/video-comment.component.ts | 2 +- .../src/app/videos/+video-watch/comment/video-comment.service.ts | 7 +++++-- 2 files changed, 6 insertions(+), 3 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 7c664ca60..9176de80f 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 @@ -90,7 +90,7 @@ export class VideoCommentComponent implements OnInit, OnChanges { private init () { this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, { - allowedTags: [ 'p', 'span' ] + allowedTags: [ 'p', 'span', 'br' ] }) this.newParentComments = this.parentComments.concat([ this.comment ]) diff --git a/client/src/app/videos/+video-watch/comment/video-comment.service.ts b/client/src/app/videos/+video-watch/comment/video-comment.service.ts index c42f55496..14d32b1aa 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment.service.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment.service.ts @@ -2,6 +2,7 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' import 'rxjs/add/operator/catch' import 'rxjs/add/operator/map' +import { immutableAssign, lineFeedToHtml } from '@app/shared/misc/utils' import { Observable } from 'rxjs/Observable' import { ResultList } from '../../../../../../shared/models' import { @@ -26,16 +27,18 @@ export class VideoCommentService { addCommentThread (videoId: number | string, comment: VideoCommentCreate) { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comment-threads' + const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, comment) + return this.authHttp.post(url, normalizedComment) .map(data => this.extractVideoComment(data['comment'])) .catch(this.restExtractor.handleError) } addCommentReply (videoId: number | string, inReplyToCommentId: number, comment: VideoCommentCreate) { const url = VideoCommentService.BASE_VIDEO_URL + videoId + '/comments/' + inReplyToCommentId + const normalizedComment = lineFeedToHtml(comment, 'text') - return this.authHttp.post(url, comment) + return this.authHttp.post(url, normalizedComment) .map(data => this.extractVideoComment(data['comment'])) .catch(this.restExtractor.handleError) } -- cgit v1.2.3