]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/videos/+video-watch/comment/video-comment.component.ts
Add links support in comments
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / +video-watch / comment / video-comment.component.ts
index 9176de80f4a2e1e520001fbfb29c68388deeaa2f..0224132ac9b53cee3a5f449de3310aee9b3463bf 100644 (file)
@@ -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 ])
   }
 }