]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Correct break line display for re-draft comments
authorKimsible <2324615-kimsible@users.noreply.gitlab.com>
Fri, 6 Nov 2020 16:40:40 +0000 (17:40 +0100)
committerRigel Kent <par@rigelk.eu>
Fri, 6 Nov 2020 17:14:15 +0000 (18:14 +0100)
client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts
client/src/app/+videos/+video-watch/comment/video-comments.component.ts

index c1d0032cc023193b7437d180d0685fc699fe4419..d746a614b4395510a87b326e754eb0cfd6dc7f4d 100644 (file)
@@ -183,7 +183,11 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
         this.textareaElement.nativeElement.focus()
       }
 
+      // Scroll to textarea
       this.textareaElement.nativeElement.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'nearest' })
+
+      // Use the native textarea autosize according to the text's break lines
+      this.textareaElement.nativeElement.dispatchEvent(new Event('input'))
     })
 
     this.form.patchValue({ text })
index 79627b1af1bc82e4bb642614daf74f9813bbd5d7..602bd8050bbe03f184472bc8f7390a77378e93bf 100644 (file)
@@ -199,10 +199,13 @@ export class VideoCommentsComponent implements OnInit, OnChanges, OnDestroy {
     if (confirm) {
       this.inReplyToCommentId = commentToRedraft.inReplyToCommentId
 
+      // Display <br /> tag as a break line for editing
+      const commentToRedraftText = commentToRedraft.text.replace(/<br.?\/?>/g, '\r\n')
+
       if (commentToRedraft.threadId === commentToRedraft.id) {
-        this.commentThreadRedraftValue = commentToRedraft.text
+        this.commentThreadRedraftValue = commentToRedraftText
       } else {
-        this.commentReplyRedraftValue = commentToRedraft.text
+        this.commentReplyRedraftValue = commentToRedraftText
       }
 
     }