From 665aa857d75c1aa2d1c26a21545760fbb7575416 Mon Sep 17 00:00:00 2001 From: schlagmichdoch Date: Tue, 17 Jan 2023 10:47:44 +0100 Subject: [PATCH] revert div to input conversion to be able to insert linebreaks to messages --- public/index.html | 2 +- public/scripts/ui.js | 11 +++++++---- public/styles.css | 6 ++++++ 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/public/index.html b/public/index.html index 1f90077..1d6f077 100644 --- a/public/index.html +++ b/public/index.html @@ -163,7 +163,7 @@

Send a Message

- +
Cancel diff --git a/public/scripts/ui.js b/public/scripts/ui.js index 2783e8a..43a1542 100644 --- a/public/scripts/ui.js +++ b/public/scripts/ui.js @@ -915,8 +915,9 @@ class SendTextDialog extends Dialog { if (e.code === "Escape") { this.hide(); } - if (e.code === "Enter" && (!e.ctrlKey && !e.metaKey)) { - e.preventDefault(); + if (e.code === "Enter" && (e.ctrlKey || e.metaKey)) { + this._send(); + this.hide(); } } } @@ -930,7 +931,9 @@ class SendTextDialog extends Dialog { const sel = window.getSelection(); this.$text.focus(); - this.$text.select(); + range.selectNodeContents(this.$text); + sel.removeAllRanges(); + sel.addRange(range); } _handleShareTargetText() { @@ -942,7 +945,7 @@ class SendTextDialog extends Dialog { _send() { Events.fire('send-text', { to: this._recipient, - text: this.$text.value + text: this.$text.innerText }); this.$text.value = ""; } diff --git a/public/styles.css b/public/styles.css index 4160435..adf7768 100644 --- a/public/styles.css +++ b/public/styles.css @@ -469,6 +469,12 @@ x-dialog .font-subheading { padding-bottom: 5px; } +/* Send Text Dialog */ + +#textInput { + min-height: 120px; +} + /* Receive Text Dialog */ #receiveTextDialog #text {