mirror of
https://github.com/m1k1o/neko.git
synced 2026-11-03 00:11:48 -06:00
client: show clipboard fallback button in Safari
Safari's clipboard.readText() support is unreliable, so treat it the same way as Firefox and always show the manual clipboard fallback. Fixes #706
This commit is contained in:
@@ -333,6 +333,10 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
get clipboard_read_available() {
|
get clipboard_read_available() {
|
||||||
|
const ua = navigator.userAgent
|
||||||
|
// Chrome/Chromium-based UAs also contain "Safari", so only match real Safari.
|
||||||
|
const isSafari = ua.indexOf('Safari') !== -1 && ua.indexOf('Chrome') === -1 && ua.indexOf('Chromium') === -1
|
||||||
|
|
||||||
return (
|
return (
|
||||||
'clipboard' in navigator &&
|
'clipboard' in navigator &&
|
||||||
typeof navigator.clipboard.readText === 'function' &&
|
typeof navigator.clipboard.readText === 'function' &&
|
||||||
@@ -340,7 +344,10 @@
|
|||||||
// instead it hangs when reading clipboard, until user clicks on the page
|
// instead it hangs when reading clipboard, until user clicks on the page
|
||||||
// and the click itself is not handled by the page at all, also the clipboard
|
// and the click itself is not handled by the page at all, also the clipboard
|
||||||
// reads always fail with "Clipboard read operation is not allowed."
|
// reads always fail with "Clipboard read operation is not allowed."
|
||||||
navigator.userAgent.indexOf('Firefox') == -1
|
ua.indexOf('Firefox') == -1 &&
|
||||||
|
// Safari's clipboard read support is unreliable (requires user gesture, often
|
||||||
|
// throws NotAllowedError), so always show the fallback button there too.
|
||||||
|
!isSafari
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user