Revert "fix textarea for sending messages is not editable on some iOS devices (#163)"

This reverts commit 1669fe7d75.
This commit is contained in:
schlagmichdoch 2023-10-11 18:56:07 +02:00
parent d46f57d8ec
commit 38a80d2d34
6 changed files with 12 additions and 10 deletions

View file

@ -412,7 +412,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="column fw"> <div class="column fw">
<textarea title="Message" class="textarea" wrap="off" autofocus></textarea> <div id="text-input" title="Message" class="textarea" role="textbox" autocapitalize="none" spellcheck="false" autofocus contenteditable></div>
</div> </div>
</div> </div>
<div class="button-row row-reverse"> <div class="button-row row-reverse">

View file

@ -1724,7 +1724,7 @@ class SendTextDialog extends Dialog {
constructor() { constructor() {
super('send-text-dialog'); super('send-text-dialog');
Events.on('text-recipient', e => this._onRecipient(e.detail.peerId, e.detail.deviceName)); Events.on('text-recipient', e => this._onRecipient(e.detail.peerId, e.detail.deviceName));
this.$text = this.$el.querySelector('.textarea'); this.$text = this.$el.querySelector('#text-input');
this.$peerDisplayName = this.$el.querySelector('.display-name'); this.$peerDisplayName = this.$el.querySelector('.display-name');
this.$form = this.$el.querySelector('form'); this.$form = this.$el.querySelector('form');
this.$submit = this.$el.querySelector('button[type="submit"]'); this.$submit = this.$el.querySelector('button[type="submit"]');
@ -1745,7 +1745,7 @@ class SendTextDialog extends Dialog {
} }
_textInputEmpty() { _textInputEmpty() {
return !this.$text.value || this.$text.value === "\n"; return !this.$text.innerText || this.$text.innerText === "\n";
} }
_onChange(e) { _onChange(e) {
@ -1767,6 +1767,7 @@ class SendTextDialog extends Dialog {
const range = document.createRange(); const range = document.createRange();
const sel = window.getSelection(); const sel = window.getSelection();
this.$text.focus();
range.selectNodeContents(this.$text); range.selectNodeContents(this.$text);
sel.removeAllRanges(); sel.removeAllRanges();
sel.addRange(range); sel.addRange(range);
@ -1780,7 +1781,7 @@ class SendTextDialog extends Dialog {
_send() { _send() {
Events.fire('send-text', { Events.fire('send-text', {
to: this.correspondingPeerId, to: this.correspondingPeerId,
text: this.$text.value text: this.$text.innerText
}); });
this.$text.value = ""; this.$text.value = "";
this.hide(); this.hide();

View file

@ -1042,7 +1042,7 @@ x-dialog .dialog-subheader {
padding-bottom: 0; padding-bottom: 0;
} }
#send-text-dialog .textarea { #text-input {
min-height: 200px; min-height: 200px;
width: 100%; width: 100%;
} }

View file

@ -417,7 +417,7 @@
</div> </div>
<div class="row"> <div class="row">
<div class="column fw"> <div class="column fw">
<textarea title="Message" class="textarea" wrap="off" autofocus></textarea> <div id="text-input" title="Message" class="textarea" role="textbox" autocapitalize="none" spellcheck="false" autofocus contenteditable></div>
</div> </div>
</div> </div>
<div class="button-row row-reverse"> <div class="button-row row-reverse">

View file

@ -1726,7 +1726,7 @@ class SendTextDialog extends Dialog {
constructor() { constructor() {
super('send-text-dialog'); super('send-text-dialog');
Events.on('text-recipient', e => this._onRecipient(e.detail.peerId, e.detail.deviceName)); Events.on('text-recipient', e => this._onRecipient(e.detail.peerId, e.detail.deviceName));
this.$text = this.$el.querySelector('.textarea'); this.$text = this.$el.querySelector('#text-input');
this.$peerDisplayName = this.$el.querySelector('.display-name'); this.$peerDisplayName = this.$el.querySelector('.display-name');
this.$form = this.$el.querySelector('form'); this.$form = this.$el.querySelector('form');
this.$submit = this.$el.querySelector('button[type="submit"]'); this.$submit = this.$el.querySelector('button[type="submit"]');
@ -1747,7 +1747,7 @@ class SendTextDialog extends Dialog {
} }
_textInputEmpty() { _textInputEmpty() {
return !this.$text.value || this.$text.value === "\n"; return !this.$text.innerText || this.$text.innerText === "\n";
} }
_onChange(e) { _onChange(e) {
@ -1769,6 +1769,7 @@ class SendTextDialog extends Dialog {
const range = document.createRange(); const range = document.createRange();
const sel = window.getSelection(); const sel = window.getSelection();
this.$text.focus();
range.selectNodeContents(this.$text); range.selectNodeContents(this.$text);
sel.removeAllRanges(); sel.removeAllRanges();
sel.addRange(range); sel.addRange(range);
@ -1782,7 +1783,7 @@ class SendTextDialog extends Dialog {
_send() { _send() {
Events.fire('send-text', { Events.fire('send-text', {
to: this.correspondingPeerId, to: this.correspondingPeerId,
text: this.$text.value text: this.$text.innerText
}); });
this.$text.value = ""; this.$text.value = "";
this.hide(); this.hide();

View file

@ -1072,7 +1072,7 @@ x-dialog .dialog-subheader {
padding-bottom: 0; padding-bottom: 0;
} }
#send-text-dialog .textarea { #text-input {
min-height: 200px; min-height: 200px;
width: 100%; width: 100%;
} }