Fix editor integration and add snippingtool://edit URL

- Fix menu button by deferring NSOpenPanel to next run loop
- Add snippingtool://edit URL to open file editor directly
- Add app activation before showing open panel (LSUIElement fix)
- Remove debug logging

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-07-01 18:25:07 +02:00
co-authored by Claude Opus 4.6
parent 78d6809445
commit 8c73c5fbc5
+23 -8
View File
@@ -116,6 +116,11 @@ final class AppCoordinator: ObservableObject {
.value?.lowercased() ?? "false" .value?.lowercased() ?? "false"
let openEditor = ["true", "1", "yes"].contains(wantsEditor) let openEditor = ["true", "1", "yes"].contains(wantsEditor)
if modeString == "edit" {
openEditorForFile()
return
}
let mode: CaptureMode? let mode: CaptureMode?
switch modeString { switch modeString {
case "fullscreen", "full", "full-screen", "screen": case "fullscreen", "full", "full-screen", "screen":
@@ -196,17 +201,27 @@ final class AppCoordinator: ObservableObject {
guard let url = lastCapturedURL, guard let url = lastCapturedURL,
FileManager.default.fileExists(atPath: url.path), FileManager.default.fileExists(atPath: url.path),
let image = NSImage(contentsOf: url) else { return } let image = NSImage(contentsOf: url) else { return }
openEditor(image: image, sourceURL: url) DispatchQueue.main.async {
self.openEditor(image: image, sourceURL: url)
}
} }
func openEditorForFile() { func openEditorForFile() {
let panel = NSOpenPanel() DispatchQueue.main.async {
panel.allowedContentTypes = [.png, .jpeg, .tiff, .bmp] NSApplication.shared.setActivationPolicy(.regular)
panel.canChooseDirectories = false NSApplication.shared.activate(ignoringOtherApps: true)
panel.allowsMultipleSelection = false
guard panel.runModal() == .OK, let url = panel.url, let panel = NSOpenPanel()
let image = NSImage(contentsOf: url) else { return } panel.allowedContentTypes = [.png, .jpeg, .tiff, .bmp]
openEditor(image: image, sourceURL: url) panel.canChooseDirectories = false
panel.allowsMultipleSelection = false
if panel.runModal() == .OK, let url = panel.url,
let image = NSImage(contentsOf: url) {
self.openEditor(image: image, sourceURL: url)
} else {
NSApplication.shared.setActivationPolicy(.accessory)
}
}
} }
private func openEditor(image: NSImage, sourceURL: URL) { private func openEditor(image: NSImage, sourceURL: URL) {