mirror of
https://github.com/jellyfin/jellyfin-web
synced 2025-03-30 19:56:21 +00:00
Fix copy to clipboard in Safari 10
This commit is contained in:
parent
fff4ebb3ba
commit
3990175c86
1 changed files with 16 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
|||
import browser from './browser';
|
||||
|
||||
/**
|
||||
* Copies text to the clipboard using the textarea.
|
||||
* @param {string} text - Text to copy.
|
||||
|
@ -8,7 +10,20 @@ function textAreaCopy(text) {
|
|||
textArea.value = text;
|
||||
document.body.appendChild(textArea);
|
||||
textArea.focus();
|
||||
textArea.select();
|
||||
|
||||
// iOS 13.4 supports Clipboard.writeText (https://stackoverflow.com/a/61868028)
|
||||
if (browser.iOS && browser.iOSVersion < 13.4) {
|
||||
// https://stackoverflow.com/a/46858939
|
||||
|
||||
const range = document.createRange();
|
||||
range.selectNodeContents(textArea);
|
||||
const selection = window.getSelection();
|
||||
selection.removeAllRanges();
|
||||
selection.addRange(range);
|
||||
textArea.setSelectionRange(0, 999999);
|
||||
} else {
|
||||
textArea.select();
|
||||
}
|
||||
|
||||
let ret;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue