From 3d9eaae318670986fedab257b8be344c9b43d8d5 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Tue, 20 Feb 2018 11:04:21 +0100 Subject: Add links support in comments --- .../+video-watch/comment/video-comment-add.component.ts | 2 +- .../videos/+video-watch/comment/video-comment.component.ts | 12 ++++++++++-- .../app/videos/+video-watch/comment/video-comment.service.ts | 6 ++++-- 3 files changed, 15 insertions(+), 5 deletions(-) (limited to 'client/src/app/videos/+video-watch') diff --git a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts index 9e499d829..183cde000 100644 --- a/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts +++ b/client/src/app/videos/+video-watch/comment/video-comment-add.component.ts @@ -2,7 +2,7 @@ import { Component, ElementRef, EventEmitter, Input, OnInit, Output, ViewChild } import { FormBuilder, FormGroup } from '@angular/forms' import { NotificationsService } from 'angular2-notifications' import { Observable } from 'rxjs/Observable' -import { VideoCommentCreate, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' +import { VideoCommentCreate } from '../../../../../../shared/models/videos/video-comment.model' import { FormReactive } from '../../../shared' import { VIDEO_COMMENT_TEXT } from '../../../shared/forms/form-validators/video-comment' import { User } from '../../../shared/users' 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 9176de80f..0224132ac 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 @@ -1,4 +1,5 @@ import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' +import { MarkdownService } from '@app/videos/shared' import * as sanitizeHtml from 'sanitize-html' import { Account as AccountInterface } from '../../../../../../shared/models/actors' import { UserRight } from '../../../../../../shared/models/users' @@ -29,7 +30,10 @@ export class VideoCommentComponent implements OnInit, OnChanges { sanitizedCommentHTML = '' newParentComments = [] - constructor (private authService: AuthService) {} + constructor ( + private authService: AuthService, + private markdownService: MarkdownService + ) {} get user () { return this.authService.getUser() @@ -90,9 +94,13 @@ export class VideoCommentComponent implements OnInit, OnChanges { private init () { this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, { - allowedTags: [ 'p', 'span', 'br' ] + allowedTags: [ 'a', 'p', 'span', 'br' ], + allowedSchemes: [ 'http', 'https' ] }) + // Convert possible markdown to html + this.sanitizedCommentHTML = this.markdownService.linkify(this.comment.text) + 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 14d32b1aa..470af1230 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 @@ -1,12 +1,14 @@ import { HttpClient, HttpParams } from '@angular/common/http' import { Injectable } from '@angular/core' +import { lineFeedToHtml } from '@app/shared/misc/utils' +import { MarkdownService } from '@app/videos/shared' 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 { - VideoComment as VideoCommentServerModel, VideoCommentCreate, + VideoComment as VideoCommentServerModel, + VideoCommentCreate, VideoCommentThreadTree } from '../../../../../../shared/models/videos/video-comment.model' import { environment } from '../../../../environments/environment' -- cgit v1.2.3