mirror of
https://github.com/liamcottle/reticulum-meshchat.git
synced 2026-04-28 00:20:48 +00:00
adding a new line in message composer should add it where the cursor is
This commit is contained in:
parent
1bad77553c
commit
59eba2ff64
1 changed files with 17 additions and 1 deletions
|
|
@ -316,6 +316,7 @@
|
|||
|
||||
<!-- text input -->
|
||||
<textarea
|
||||
ref="message-input"
|
||||
id="message-input"
|
||||
:readonly="isSendingMessage"
|
||||
v-model="newMessageText"
|
||||
|
|
@ -1402,7 +1403,22 @@ export default {
|
|||
});
|
||||
},
|
||||
addNewLine: function() {
|
||||
this.newMessageText += "\n";
|
||||
|
||||
// get cursor position for message input
|
||||
const input = this.$refs["message-input"];
|
||||
const cursorPosition = input.selectionStart;
|
||||
|
||||
// insert a newline character after the cursor position
|
||||
const text = this.newMessageText;
|
||||
this.newMessageText = text.slice(0, cursorPosition) + '\n' + text.slice(cursorPosition);
|
||||
|
||||
// move cursor to the position after the added newline
|
||||
const newCursorPosition = cursorPosition + 1;
|
||||
this.$nextTick(() => {
|
||||
input.selectionStart = newCursorPosition;
|
||||
input.selectionEnd = newCursorPosition;
|
||||
});
|
||||
|
||||
},
|
||||
onEnterPressed: function() {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue