revert div to input conversion to be able to insert linebreaks to messages

This commit is contained in:
schlagmichdoch 2023-01-17 10:47:44 +01:00
parent 5525caa766
commit 665aa857d7
3 changed files with 14 additions and 5 deletions

View file

@ -163,7 +163,7 @@
<x-background class="full center"> <x-background class="full center">
<x-paper shadow="2"> <x-paper shadow="2">
<h3>Send a Message</h3> <h3>Send a Message</h3>
<input id="textInput" class="textarea w100" role="textbox" placeholder="Send a message" autocomplete="off" autofocus contenteditable> <div id="textInput" class="textarea" role="textbox" placeholder="Send a message" autocomplete="off" autofocus contenteditable></div>
<div class="row-reverse"> <div class="row-reverse">
<button class="button" type="submit" close>Send</button> <button class="button" type="submit" close>Send</button>
<a class="button" close>Cancel</a> <a class="button" close>Cancel</a>

View file

@ -915,8 +915,9 @@ class SendTextDialog extends Dialog {
if (e.code === "Escape") { if (e.code === "Escape") {
this.hide(); this.hide();
} }
if (e.code === "Enter" && (!e.ctrlKey && !e.metaKey)) { if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) {
e.preventDefault(); this._send();
this.hide();
} }
} }
} }
@ -930,7 +931,9 @@ class SendTextDialog extends Dialog {
const sel = window.getSelection(); const sel = window.getSelection();
this.$text.focus(); this.$text.focus();
this.$text.select(); range.selectNodeContents(this.$text);
sel.removeAllRanges();
sel.addRange(range);
} }
_handleShareTargetText() { _handleShareTargetText() {
@ -942,7 +945,7 @@ class SendTextDialog extends Dialog {
_send() { _send() {
Events.fire('send-text', { Events.fire('send-text', {
to: this._recipient, to: this._recipient,
text: this.$text.value text: this.$text.innerText
}); });
this.$text.value = ""; this.$text.value = "";
} }

View file

@ -469,6 +469,12 @@ x-dialog .font-subheading {
padding-bottom: 5px; padding-bottom: 5px;
} }
/* Send Text Dialog */
#textInput {
min-height: 120px;
}
/* Receive Text Dialog */ /* Receive Text Dialog */
#receiveTextDialog #text { #receiveTextDialog #text {