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
+12
-4
@@ -756,6 +756,12 @@ struct IngestError: LocalizedError {
|
||||
IngestError(message: "“\(name.prefix(40))” is a folder, not an image.")
|
||||
}
|
||||
|
||||
/// A file the drag named but the disk can no longer stat — moved or
|
||||
/// deleted between drag and drop (or a URL that never was a file).
|
||||
static func missing(_ name: String) -> IngestError {
|
||||
IngestError(message: "“\(name.prefix(40))” couldn’t be read — it may have moved since the drag began.")
|
||||
}
|
||||
|
||||
/// assets/ exists as a symlink or a file — never write through it
|
||||
/// (research/promote posture: the #34 rail would refuse the send).
|
||||
static func hostileAssets() -> IngestError {
|
||||
@@ -790,10 +796,12 @@ nonisolated extension PostStore {
|
||||
// AS a link (finish-audit 2026-11-02), and the #34 rail then
|
||||
// refuses the whole send — nothing enters assets/ that can't ship.
|
||||
let values = try? source.resourceValues(forKeys: [.isDirectoryKey, .isSymbolicLinkKey])
|
||||
guard source.isFileURL, let values,
|
||||
values.isDirectory != true, values.isSymbolicLink != true
|
||||
else {
|
||||
throw values?.isSymbolicLink == true ? IngestError.isLink(name) : IngestError.isFolder(name)
|
||||
guard source.isFileURL, let values else { throw IngestError.missing(name) }
|
||||
if values.isSymbolicLink == true {
|
||||
throw IngestError.isLink(name)
|
||||
}
|
||||
if values.isDirectory == true {
|
||||
throw IngestError.isFolder(name)
|
||||
}
|
||||
let assets = pieceFolder.appendingPathComponent("assets", isDirectory: true)
|
||||
if FileManager.default.fileExists(atPath: assets.path) {
|
||||
|
||||
Reference in new issue
Block a user