]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Add emoji list to markdown infos
authorkimsible <kimsible@users.noreply.github.com>
Sun, 9 Aug 2020 14:20:31 +0000 (16:20 +0200)
committerChocobozzz <chocobozzz@cpy.re>
Fri, 14 Aug 2020 13:03:38 +0000 (15:03 +0200)
client/src/app/+videos/+video-watch/comment/video-comment-add.component.html
client/src/app/+videos/+video-watch/comment/video-comment-add.component.scss
client/src/app/+videos/+video-watch/comment/video-comment-add.component.ts

index 4af0d277cc5be2c7207a97d19896e222a4dbacb3..6b3d39730572c837b8b2f66580a13b3fb6fe0f60 100644 (file)
@@ -3,12 +3,14 @@
     <img [src]="getAvatarUrl()" alt="Avatar" />
 
     <div class="form-group">
-      <textarea i18n-placeholder placeholder="Add comment..." myAutoResize [readonly]="(user === null) ? true : false"
-        (click)="openVisitorModal($event)" formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }"
-        (keyup.control.enter)="onValidKey()" (keyup.meta.enter)="onValidKey()" #textarea>
+      <textarea i18n-placeholder placeholder="Add comment..." myAutoResize
+                [readonly]="(user === null) ? true : false"
+                (click)="openVisitorModal($event)"
+                formControlName="text" [ngClass]="{ 'input-error': formErrors['text'] }"
+                (keyup.control.enter)="onValidKey()" (keyup.meta.enter)="onValidKey()" #textarea>
 
       </textarea>
-      <my-help class="markdown-guide" helpType="custom" iconName="markdown" i18n-title title="Markdown compatible">
+      <my-help class="markdown-guide" helpType="custom" iconName="markdown" tooltipPlacement="left auto" i18n-title title="Markdown compatible">
         <ng-template ptTemplate="customHtml">
           <span i18n>Markdown compatible that supports:</span>
 
@@ -27,6 +29,7 @@
             <li>
               <span i18n>Emoji markup</span>
               <code>:smile:</code>
+              <div><a href="" (click)="openEmojiModal($event)" i18n>See complete list</a></div>
             </li>
           </ul>
         </ng-template>
@@ -50,7 +53,7 @@
 <ng-template #visitorModal let-modal>
   <div class="modal-header">
     <h4 class="modal-title" id="modal-basic-title" i18n>You are one step away from commenting</h4>
-    <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hideVisitorModal()"></my-global-icon>
+    <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hideModals()"></my-global-icon>
   </div>
   <div class="modal-body">
     <span i18n>
@@ -66,7 +69,7 @@
   <div class="modal-footer inputs">
     <input
       type="button" role="button" i18n-value value="Cancel" class="action-button action-button-cancel"
-      (click)="hideVisitorModal()" (key.enter)="hideVisitorModal()"
+      (click)="hideModals()" (key.enter)="hideModals()"
     >
 
     <input
     >
   </div>
 </ng-template>
+
+<ng-template #emojiModal>
+  <div class="modal-header">
+    <h4 class="modal-title" id="modal-basic-title" i18n>Markdown Emoji List</h4>
+    <my-global-icon iconName="cross" aria-label="Close" role="button" (click)="hideModals()"></my-global-icon>
+  </div>
+  <div class="modal-body">
+    <table class="table-emoji" *ngFor="let emojiMarkup of emojiMarkupList | keyvalue">
+      <tr>
+        <td>
+          <span>{{ emojiMarkup.value }}</span>
+        </td>
+        <td>
+          <code>:{{ emojiMarkup.key }}:</code>
+        </td>
+      </tr>
+    </table>
+  </div>
+</ng-template>
index daaf337c8608178800fd4e097104fce354d1d2aa..2be187670f228278b4a4c1426de7fcfd5692fe8a 100644 (file)
@@ -99,6 +99,16 @@ form {
   }
 }
 
+.table-emoji {
+  td {
+    &:first-child {
+      width: 20px;
+    }
+
+    vertical-align: top;
+  }
+}
+
 @media screen and (max-width: 600px) {
   textarea, .comment-buttons button {
     font-size: 14px !important;
index c6e9c73b8f2357c1cbe357dfb05521e55e4c806e..3d0611a2df6e6e36cc5e8e5919be6e931afeac2a 100644 (file)
@@ -27,6 +27,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
   @Output() cancel = new EventEmitter()
 
   @ViewChild('visitorModal', { static: true }) visitorModal: NgbModal
+  @ViewChild('emojiModal', { static: true }) emojiModal: NgbModal
   @ViewChild('textarea', { static: true }) textareaElement: ElementRef
 
   addingComment = false
@@ -44,6 +45,12 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
     super()
   }
 
+  get emojiMarkupList () {
+    const emojiMarkup = require('markdown-it-emoji/lib/data/light.json')
+
+    return emojiMarkup
+  }
+
   ngOnInit () {
     this.buildForm({
       text: this.videoCommentValidatorsService.VIDEO_COMMENT_TEXT
@@ -97,7 +104,12 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
     }
   }
 
-  hideVisitorModal () {
+  openEmojiModal (event: any) {
+    event.preventDefault()
+    this.modalService.open(this.emojiModal, { backdrop: true })
+  }
+
+  hideModals () {
     this.modalService.dismissAll()
   }
 
@@ -145,7 +157,7 @@ export class VideoCommentAddComponent extends FormReactive implements OnChanges,
   }
 
   gotoLogin () {
-    this.hideVisitorModal()
+    this.hideModals()
     this.router.navigate([ '/login' ])
   }