mirror of
https://github.com/leonboe1/QuickDrop.git
synced 2026-11-20 21:36:00 +00:00
Add support for sharing plain text
This commit is contained in:
1 parent
a76983df36
commit
f800975607
5 files changed
+67
-39
No files matched your search
@@ -130,32 +130,14 @@ class AppDelegate: NSObject, NSApplicationDelegate, UNUserNotificationCenterDele
|
||||
|
||||
|
||||
@objc func sendClipboard() {
|
||||
if let fileURL = saveClipboardToTempFile() {
|
||||
if let fileURL = ClipboardManager.saveClipboardToTempFile() {
|
||||
|
||||
let sharingService = NSSharingService(named: NSSharingService.Name("com.leonboettger.neardrop.ShareExtension"))
|
||||
|
||||
sharingService?.perform(withItems: [fileURL])
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func saveClipboardToTempFile() -> URL? {
|
||||
let pasteboard = NSPasteboard.general
|
||||
let clipboardString = pasteboard.string(forType: .string) ?? ""
|
||||
|
||||
let tempDirectory = FileManager.default.temporaryDirectory
|
||||
let fileURL = tempDirectory.appendingPathComponent("Clipboard".localized() + ".txt")
|
||||
|
||||
do {
|
||||
try clipboardString.write(to: fileURL, atomically: true, encoding: .utf8)
|
||||
return fileURL
|
||||
} catch {
|
||||
log("Failed to write file: \(error)")
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@objc func openWelcomeScreen() {
|
||||
// Create the welcome screen SwiftUI view
|
||||
let welcomeView = WelcomeScreen(openPlusScreen: openPlusScreen, checkForNetworkIssues: performDeviceToDeviceCheck)
|
||||
|
||||
Reference in new issue
Block a user