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:
@@ -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() {
|
||||||
|
DispatchQueue.main.async {
|
||||||
|
NSApplication.shared.setActivationPolicy(.regular)
|
||||||
|
NSApplication.shared.activate(ignoringOtherApps: true)
|
||||||
|
|
||||||
let panel = NSOpenPanel()
|
let panel = NSOpenPanel()
|
||||||
panel.allowedContentTypes = [.png, .jpeg, .tiff, .bmp]
|
panel.allowedContentTypes = [.png, .jpeg, .tiff, .bmp]
|
||||||
panel.canChooseDirectories = false
|
panel.canChooseDirectories = false
|
||||||
panel.allowsMultipleSelection = false
|
panel.allowsMultipleSelection = false
|
||||||
guard panel.runModal() == .OK, let url = panel.url,
|
if panel.runModal() == .OK, let url = panel.url,
|
||||||
let image = NSImage(contentsOf: url) else { return }
|
let image = NSImage(contentsOf: url) {
|
||||||
openEditor(image: image, sourceURL: 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) {
|
||||||
|
|||||||
Reference in New Issue
Block a user