Add emoji list to markdown infos

This commit is contained in:
kimsible 2020-08-09 16:20:31 +02:00 committed by Chocobozzz
parent fd9c3c8d66
commit ee3bd9db05
3 changed files with 52 additions and 8 deletions

View 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
@ -75,3 +78,22 @@
>
</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>

View 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;

View 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' ])
}