mirror of
https://github.com/bitwarden/browser
synced 2024-12-24 17:11:55 +01:00
Fix copying TOTP not working in Safari (#1598)
This commit is contained in:
parent
3e79dd245b
commit
e5764ee16e
@ -21,6 +21,13 @@ class SafariWebExtensionHandler: NSObject, NSExtensionRequestHandling {
|
||||
let pasteboard = NSPasteboard.general
|
||||
response.userInfo = [ SFExtensionMessageKey: pasteboard.pasteboardItems?.first?.string(forType: .string) as Any ]
|
||||
break
|
||||
case "copyToClipboard":
|
||||
guard let msg = message?["data"] as? String else {
|
||||
return
|
||||
}
|
||||
let pasteboard = NSPasteboard.general
|
||||
pasteboard.clearContents()
|
||||
pasteboard.setString(msg, forType: .string)
|
||||
case "showPopover":
|
||||
SFSafariApplication.getActiveWindow { win in
|
||||
win?.getToolbarItem(completionHandler: { item in
|
||||
|
@ -190,7 +190,14 @@ export default class BrowserPlatformUtilsService implements PlatformUtilsService
|
||||
}
|
||||
const clearing = options ? !!options.clearing : false;
|
||||
const clearMs: number = options && options.clearMs ? options.clearMs : null;
|
||||
if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) {
|
||||
|
||||
if (this.isSafari()) {
|
||||
SafariApp.sendMessageToApp('copyToClipboard', text).then(() => {
|
||||
if (!clearing && this.clipboardWriteCallback != null) {
|
||||
this.clipboardWriteCallback(text, clearMs);
|
||||
}
|
||||
});
|
||||
} else if (this.isFirefox() && (win as any).navigator.clipboard && (win as any).navigator.clipboard.writeText) {
|
||||
(win as any).navigator.clipboard.writeText(text).then(() => {
|
||||
if (!clearing && this.clipboardWriteCallback != null) {
|
||||
this.clipboardWriteCallback(text, clearMs);
|
||||
|
Loading…
Reference in New Issue
Block a user