aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/src/app/videos/+video-watch/comment/video-comment.component.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/src/app/videos/+video-watch/comment/video-comment.component.ts')
-rw-r--r--client/src/app/videos/+video-watch/comment/video-comment.component.ts29
1 files changed, 21 insertions, 8 deletions
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 0224132ac..8f2d79ec1 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,5 +1,5 @@
1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core' 1import { Component, EventEmitter, Input, OnChanges, OnInit, Output } from '@angular/core'
2import { MarkdownService } from '@app/videos/shared' 2import { LinkifierService } from '@app/videos/+video-watch/comment/linkifier.service'
3import * as sanitizeHtml from 'sanitize-html' 3import * as sanitizeHtml from 'sanitize-html'
4import { Account as AccountInterface } from '../../../../../../shared/models/actors' 4import { Account as AccountInterface } from '../../../../../../shared/models/actors'
5import { UserRight } from '../../../../../../shared/models/users' 5import { UserRight } from '../../../../../../shared/models/users'
@@ -31,8 +31,8 @@ export class VideoCommentComponent implements OnInit, OnChanges {
31 newParentComments = [] 31 newParentComments = []
32 32
33 constructor ( 33 constructor (
34 private authService: AuthService, 34 private linkifierService: LinkifierService,
35 private markdownService: MarkdownService 35 private authService: AuthService
36 ) {} 36 ) {}
37 37
38 get user () { 38 get user () {
@@ -93,14 +93,27 @@ export class VideoCommentComponent implements OnInit, OnChanges {
93 } 93 }
94 94
95 private init () { 95 private init () {
96 this.sanitizedCommentHTML = sanitizeHtml(this.comment.text, { 96 // Convert possible markdown to html
97 const html = this.linkifierService.linkify(this.comment.text)
98
99 this.sanitizedCommentHTML = sanitizeHtml(html, {
97 allowedTags: [ 'a', 'p', 'span', 'br' ], 100 allowedTags: [ 'a', 'p', 'span', 'br' ],
98 allowedSchemes: [ 'http', 'https' ] 101 allowedSchemes: [ 'http', 'https' ],
102 allowedAttributes: {
103 'a': [ 'href', 'class' ]
104 },
105 transformTags: {
106 a: (tagName, attribs) => {
107 return {
108 tagName,
109 attribs: Object.assign(attribs, {
110 target: '_blank'
111 })
112 }
113 }
114 }
99 }) 115 })
100 116
101 // Convert possible markdown to html
102 this.sanitizedCommentHTML = this.markdownService.linkify(this.comment.text)
103
104 this.newParentComments = this.parentComments.concat([ this.comment ]) 117 this.newParentComments = this.parentComments.concat([ this.comment ])
105 } 118 }
106} 119}