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
@@ -71,7 +71,7 @@ final class ProseChromeView: NSView {
|
||||
}
|
||||
}
|
||||
|
||||
final class ProseListTextView: NSTextView {
|
||||
final class ProseListTextView: FileDropTextView {
|
||||
/// A fold: the marker line's buffer position + its text (the re-key
|
||||
/// identity when an edit above shifts offsets) + the hidden scope
|
||||
/// (shift-maintained by the #142 cheap path; the full pass re-derives
|
||||
@@ -338,8 +338,10 @@ final class ProseListTextView: NSTextView {
|
||||
return firstRect(forCharacterRange: NSRange(location: charIndex, length: 1), actualRange: nil).midY
|
||||
}
|
||||
|
||||
/// #141's SwiftUI entry — the window `.dropDestination`'s perform
|
||||
/// routes here after markdown forwarding is ruled out upstream.
|
||||
/// #141's ingest entry — `AppGateState.routeFileDrop` routes here
|
||||
/// from whichever surface took the drag (the text view's own drag
|
||||
/// handlers over the editor, the window `.dropDestination` elsewhere)
|
||||
/// after markdown forwarding is ruled out upstream.
|
||||
/// The drop point is read from the live pointer (NSEvent.mouseLocation
|
||||
/// — the SwiftUI closure's location proved unusable, dogfood 2026-11-02).
|
||||
/// Gates: saved piece, every file publishable (#34's mimeType set) —
|
||||
@@ -354,8 +356,10 @@ final class ProseListTextView: NSTextView {
|
||||
}
|
||||
// The publish-able set IS #34's mimeType gate — nothing the rail
|
||||
// can't ship ever enters assets/. A mixed md+image set refuses
|
||||
// here too (only pure-markdown sets are forwarded upstream).
|
||||
guard urls.allSatisfy({ Micropub.mimeType(forDestination: $0.lastPathComponent) != nil }) else {
|
||||
// here too (only pure-markdown sets are forwarded upstream), and
|
||||
// so does a web URL (a browser image drag): the extension may
|
||||
// look publishable, but nothing is on disk to copy.
|
||||
guard urls.allSatisfy({ $0.isFileURL && Micropub.mimeType(forDestination: $0.lastPathComponent) != nil }) else {
|
||||
showIngestNotice("Drop images (PNG, JPEG, GIF, WebP, SVG) or markdown — one kind at a time.")
|
||||
return false
|
||||
}
|
||||
@@ -416,7 +420,12 @@ final class ProseListTextView: NSTextView {
|
||||
private var ingestNotice: NSTextField?
|
||||
private var ingestNoticeHide: DispatchWorkItem?
|
||||
|
||||
/// The last refusal text — the observable the pins read (the strip
|
||||
/// itself is private chrome).
|
||||
private(set) var lastIngestNotice: String?
|
||||
|
||||
private func showIngestNotice(_ text: String) {
|
||||
lastIngestNotice = text
|
||||
let strip: NSTextField
|
||||
if let ingestNotice {
|
||||
strip = ingestNotice
|
||||
|
||||
Reference in new issue
Block a user