diff --git a/config.xml b/config.xml index 4248593..98c7add 100644 --- a/config.xml +++ b/config.xml @@ -1,5 +1,5 @@ - + METAsocket WowApp's awesome instant messenger for the whole Greifentanzgeschwader sabolli diff --git a/src/app/chat/chat.component.html b/src/app/chat/chat.component.html index 8f50991..33a87bb 100644 --- a/src/app/chat/chat.component.html +++ b/src/app/chat/chat.component.html @@ -14,7 +14,7 @@
- +
diff --git a/src/app/chat/chat.component.ts b/src/app/chat/chat.component.ts index 5f0368d..6cbb268 100644 --- a/src/app/chat/chat.component.ts +++ b/src/app/chat/chat.component.ts @@ -138,9 +138,11 @@ export class ChatComponent implements OnInit, AfterViewInit, AfterViewChecked, W } } - onInput(event): void { + onInput(): void { this.chatTypeArea.nativeElement.style.height = '50px'; - this.chatTypeArea.nativeElement.style.height = event.target.scrollHeight > 50 ? event.target.scrollHeight + 'px' : '50px'; + this.chatTypeArea.nativeElement.style.height = this.chatTextArea.nativeElement.scrollHeight > 50 + ? this.chatTextArea.nativeElement.scrollHeight + 'px' + : '50px'; if (this.chatTypeArea.nativeElement.clientHeight > window.innerHeight) { this.chatTypeArea.nativeElement.style.height = window.innerHeight + 'px'; @@ -154,6 +156,8 @@ export class ChatComponent implements OnInit, AfterViewInit, AfterViewChecked, W this.websocketService.sendChatMessage(this.chatTextArea.nativeElement.value); this.chatTextArea.nativeElement.value = ''; + + this.onInput(); } onLogout() { @@ -220,7 +224,7 @@ export class ChatComponent implements OnInit, AfterViewInit, AfterViewChecked, W citeUsername(username: string): void { - this.insertIntoTextareaCursorPosition('@' + username); + this.insertIntoTextareaCursorPosition('@' + username, false); } citeMessage(username: string, message: string): void @@ -319,16 +323,23 @@ export class ChatComponent implements OnInit, AfterViewInit, AfterViewChecked, W return parsedText; } - private insertIntoTextareaCursorPosition(text: string): void + private insertIntoTextareaCursorPosition(text: string, isCite: boolean = true): void { const textarea = this.chatTextArea.nativeElement; + const selectionStartBuffer = textarea.selectionStart; + const selectionEndBuffer = textarea.selectionEnd; + const textLength = textarea.value.length; - const messagePartA = textarea.value.substr(0, textarea.selectionStart) + (textarea.selectionStart > 0 ? '\n' : ''); + const messagePartA = textarea.value.substr(0, textarea.selectionStart) + (isCite && textarea.selectionStart > 0 ? '\n' : ''); const messagePartB = textarea.value.substr(textarea.selectionStart, textLength); - textarea.value = messagePartA.trim() + text + messagePartB.trim(); + textarea.value = isCite ? messagePartA + text + messagePartB : messagePartA + text + messagePartB.trim(); textarea.focus(); + textarea.selectionStart = selectionStartBuffer + text.length; + textarea.selectionEnd = selectionEndBuffer + text.length; + + this.onInput(); } private enableSendButton(): void diff --git a/src/assets/graphics/button_send.svg b/src/assets/graphics/button_send.svg new file mode 100644 index 0000000..e45ec19 --- /dev/null +++ b/src/assets/graphics/button_send.svg @@ -0,0 +1,60 @@ + + + + + + + + image/svg+xml + + + + + + +