fix #112 and differentiate between textContent and innerText

This commit is contained in:
schlagmichdoch 2023-05-26 20:24:29 +02:00
parent 27bf0fa74f
commit 520b772bc8
4 changed files with 6 additions and 6 deletions

View file

@ -1419,7 +1419,7 @@ class ReceiveTextDialog extends Dialog {
} }
async _onCopy() { async _onCopy() {
await navigator.clipboard.writeText(this.$text.textContent); await navigator.clipboard.writeText(this.$text.innerText);
Events.fire('notify-user', 'Copied to clipboard'); Events.fire('notify-user', 'Copied to clipboard');
this.hide(); this.hide();
} }
@ -1594,7 +1594,7 @@ class Toast extends Dialog {
_onNotify(message) { _onNotify(message) {
if (this.hideTimeout) clearTimeout(this.hideTimeout); if (this.hideTimeout) clearTimeout(this.hideTimeout);
this.$el.textContent = message; this.$el.innerText = message;
this.show(); this.show();
this.hideTimeout = setTimeout(_ => this.hide(), 5000); this.hideTimeout = setTimeout(_ => this.hide(), 5000);
} }

View file

@ -5,7 +5,7 @@ if (!navigator.clipboard) {
// A <span> contains the text to copy // A <span> contains the text to copy
const span = document.createElement('span'); const span = document.createElement('span');
span.textContent = text; span.innerText = text;
span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines
// Paint the span outside the viewport // Paint the span outside the viewport

View file

@ -1420,7 +1420,7 @@ class ReceiveTextDialog extends Dialog {
} }
async _onCopy() { async _onCopy() {
await navigator.clipboard.writeText(this.$text.textContent); await navigator.clipboard.writeText(this.$text.innerText);
Events.fire('notify-user', 'Copied to clipboard'); Events.fire('notify-user', 'Copied to clipboard');
this.hide(); this.hide();
} }
@ -1595,7 +1595,7 @@ class Toast extends Dialog {
_onNotify(message) { _onNotify(message) {
if (this.hideTimeout) clearTimeout(this.hideTimeout); if (this.hideTimeout) clearTimeout(this.hideTimeout);
this.$el.textContent = message; this.$el.innerText = message;
this.show(); this.show();
this.hideTimeout = setTimeout(_ => this.hide(), 5000); this.hideTimeout = setTimeout(_ => this.hide(), 5000);
} }

View file

@ -5,7 +5,7 @@ if (!navigator.clipboard) {
// A <span> contains the text to copy // A <span> contains the text to copy
const span = document.createElement('span'); const span = document.createElement('span');
span.textContent = text; span.innerText = text;
span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines span.style.whiteSpace = 'pre'; // Preserve consecutive spaces and newlines
// Paint the span outside the viewport // Paint the span outside the viewport