Fixes chatting functions for new approach (contenteditable div)

This commit is contained in:
montelale 2020-12-22 21:23:10 +01:00
parent 5467087600
commit c14c121ba5

View file

@ -315,12 +315,19 @@ class SendTextDialog extends Dialog {
this._recipient = recipient;
this._handleShareTargetText();
this.show();
this.$text.setSelectionRange(0, this.$text.value.length)
const range = document.createRange();
const sel = window.getSelection();
range.selectNodeContents(this.$text);
sel.removeAllRanges();
sel.addRange(range);
}
_handleShareTargetText() {
if (!window.shareTargetText) return;
this.$text.value = window.shareTargetText;
this.$text.textContent = window.shareTargetText;
window.shareTargetText = '';
}
@ -328,7 +335,7 @@ class SendTextDialog extends Dialog {
e.preventDefault();
Events.fire('send-text', {
to: this._recipient,
text: this.$text.value
text: this.$text.textContent
});
}
}