fix(editor): editor owns file drops on macOS 27.2
Dropping an image file on the prose editor pasted the file path instead of ingesting it (#141 follow-up, unticketed; dogfood on macOS 27.2.1). #141 was field-verified on 27.0.1, where the window-level SwiftUI dropDestination starved every deeper destination; 27.2 routes a drag to the deepest destination, and a live NSTextView registers itself for drag types, so its stock performDragOperation pasted the path and the window destination never fired — the same for a markdown file dropped on the editor. The editor text views now share a FileDropTextView base that owns the drops landing on them: URL-bearing drags route (never super) — the prose editor through the one new AppGateState.routeFileDrop (Cold Turkey guard, markdown → guest, anything else → ingestDrop), which the window destination also uses for drops landing outside the editor; the outline rows bounce; text-only drags keep the stock drop; the pasteboard probe is memoized per changeCount. A web URL refuses with the type strip, a vanished file refuses as missing. +9 tests (a real NSDraggingInfo mock drives the overrides; the router's guest/lock/ingest branches pinned), all flip-verified. Finish-audit: three reviewers; the text-drag regression and the outline rows' identical exposure fixed, two pre-existing ceilings deferred in the devlog. Rail 729/729, swiftformat 0/153, swiftlint 0.
This commit is contained in:
1 parent
64a7eaa37e
commit
46e87e678c
15 files changed
+529
-60
No files matched your search
@@ -16,11 +16,9 @@ import SwiftUI
|
||||
@MainActor
|
||||
@Observable
|
||||
final class AppGateState {
|
||||
/// #141: the live prose text view — the window-level drop destination
|
||||
/// (the ONLY destination that ever fires; nested editor-level SwiftUI
|
||||
/// targets are never consulted, and AppKit views registered for file
|
||||
/// drags are starved by it — field-verified 2026-11-02) routes image
|
||||
/// drops to the editor through this handle.
|
||||
/// #141: the live prose text view — the window-level SwiftUI destination
|
||||
/// (drops landing OUTSIDE the editor) reaches it through this handle;
|
||||
/// routing lives in `routeFileDrop`.
|
||||
let proseDrop = ProseDropBridge()
|
||||
let gateModel = EngineGateModel()
|
||||
let provisioning = ProvisioningModel()
|
||||
@@ -118,6 +116,23 @@ final class AppGateState {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #91 + #141 — the ONE file-drop router. Two surfaces reach it, never
|
||||
/// both for one drag (27.2 routing: the editor's text view when the
|
||||
/// pointer is over it, the window-level SwiftUI destination elsewhere):
|
||||
/// a PURE-markdown set opens as the guest; anything else goes to the
|
||||
/// open piece's prose ingest, which refuses loudly (drafts, mixed
|
||||
/// md+image sets, non-publishable or non-file URLs).
|
||||
/// #162: no new buffers while a Cold Turkey block holds.
|
||||
func routeFileDrop(_ urls: [URL]) -> Bool {
|
||||
guard !writingLock.isLocked else { return false }
|
||||
if urls.allSatisfy(PostStore.isMarkdown), let url = urls.first {
|
||||
posts.openExternal(url)
|
||||
return true
|
||||
}
|
||||
guard let textView = proseDrop.textView else { return false }
|
||||
return textView.ingestDrop(urls)
|
||||
}
|
||||
}
|
||||
|
||||
/// #23: no `@main` here — MuseionLauncher (MCPServer.swift) branches
|
||||
|
||||
Reference in new issue
Block a user