Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/ts/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,15 @@ function copyToClipboard(str: string): void {
const oldSelection = sel.getRangeAt(0);

el.select(); // Select the <textarea> content
document.execCommand("copy"); // Copy - only works as a result of a user action (e.g. click events)
navigator.clipboard.writeText(str); // Copy - only works as a result of a user action (e.g. click events)
document.body.removeChild(el); // Remove the <textarea> element

// restore the previous selection
sel.removeAllRanges();
sel.addRange(oldSelection);
} else {
el.select(); // Select the <textarea> content
document.execCommand("copy"); // Copy - only works as a result of a user action (e.g. click events)
navigator.clipboard.writeText(str); // Copy - only works as a result of a user action (e.g. click events)
document.body.removeChild(el); // Remove the <textarea> element
}
}
Expand Down