feat(posts): import & external markdown — S1.1 (#22)
CI / ci (push) Canceled after 0s
CI / ci (push) Canceled after 0s
External .md/.markdown opens and edits as-is in a single guest slot (File > Open... Cmd+O, drag-onto-window): SessionTarget extends EditorSession to write in place verbatim, no cursor sidecar, the #67 conflict alert reused for foreign files. Import... (Shift+Cmd+O) copies multi-select files in as Posts behind ONE Origin ask (writer default, immutable); external frontmatter keys ride verbatim with pass_state/origin set; slug/collision machinery shared with writeNew. Audit fixes folded in: BOM stripped + CRLF normalized at the trust boundary (a CRLF pair is one Swift grapheme — \n splits saw one line); unreadable files refuse to open (loadFailed — a failed read never becomes a write); dropped web links and severed symlinks guarded; ~24 lines of reviewer-flagged dead weight removed. 7 new tests; full unit + UI suite green; swiftlint clean. Map #22 stays open pending the live calibration pass (#88 posture).
This commit is contained in:
1 parent
683d697367
commit
0f1c4ef4fe
14 files changed
+691
-49
No files matched your search
@@ -38,6 +38,14 @@ struct WorkspaceView: View {
|
||||
}
|
||||
}
|
||||
}
|
||||
// #91: drag a markdown file onto the window — same guest slot as
|
||||
// File ▸ Open… Non-markdown drops are refused.
|
||||
.dropDestination(for: URL.self) { urls, _ in
|
||||
guard let url = urls.first(where: PostStore.isMarkdown) else { return false }
|
||||
gate.posts.openExternal(url)
|
||||
selection = .posts
|
||||
return true
|
||||
}
|
||||
// #21: left-edge hover slides rail+library back in as an overlay.
|
||||
// Library only while the window width allows it (#17 verdict stands:
|
||||
// a collapsed pane is not summoned by focus).
|
||||
@@ -57,9 +65,40 @@ struct WorkspaceView: View {
|
||||
}
|
||||
}
|
||||
.background(DesignTokens.background)
|
||||
// #94: the ONE Origin ask per import batch. Dismissal without an
|
||||
// answer (Esc/Cancel) drops the batch.
|
||||
.sheet(isPresented: originAskBinding) {
|
||||
OriginAskSheet(count: gate.posts.pendingImportURLs?.count ?? 0) { origin in
|
||||
gate.posts.importFiles(origin: origin, home: gate.museionHome)
|
||||
}
|
||||
}
|
||||
}
|
||||
// Collapsed floor: rail 56 + editor placeholder (export ≤920 layout).
|
||||
.frame(minWidth: 480, minHeight: 320)
|
||||
// #92/#94: the editor column lives in Posts — a guest buffer or an
|
||||
// import's opened post surfaces there, whatever pane was showing.
|
||||
.onChange(of: gate.posts.externalSession != nil) { _, isUp in
|
||||
if isUp {
|
||||
selection = .posts
|
||||
}
|
||||
}
|
||||
.onChange(of: gate.posts.selectedPostID) { _, _ in
|
||||
if gate.posts.session != nil {
|
||||
selection = .posts
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// #94: the ask presents while a batch is staged.
|
||||
private var originAskBinding: Binding<Bool> {
|
||||
Binding(
|
||||
get: { gate.posts.pendingImportURLs != nil },
|
||||
set: {
|
||||
if !$0 {
|
||||
gate.posts.cancelImport()
|
||||
}
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
@ViewBuilder
|
||||
@@ -116,6 +155,47 @@ struct WorkspaceView: View {
|
||||
}
|
||||
}
|
||||
|
||||
/// #94: the ONE Origin ask per import batch — writer (default) / ai, with the
|
||||
/// immutability line (CONTEXT.md: Origin). Answering runs the batch.
|
||||
private struct OriginAskSheet: View {
|
||||
let count: Int
|
||||
let answer: (Post.Origin) -> Void
|
||||
@Environment(\.dismiss) private var dismiss
|
||||
@State private var origin: Post.Origin = .writer
|
||||
|
||||
var body: some View {
|
||||
VStack(alignment: .leading, spacing: 12) {
|
||||
Text("Who wrote this?")
|
||||
.font(.system(size: 15, weight: .semibold, design: DesignTokens.serif))
|
||||
Text(count == 1
|
||||
? "Importing 1 file as a Post — the original is untouched."
|
||||
: "Importing \(count) files as Posts — the originals are untouched.")
|
||||
.font(.callout)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
Picker("Origin", selection: $origin) {
|
||||
Text("I wrote it (writer)").tag(Post.Origin.writer)
|
||||
Text("AI-assisted (ai)").tag(Post.Origin.ai)
|
||||
}
|
||||
.pickerStyle(.radioGroup)
|
||||
Text("Origin is stamped once and never asked again — it decides whether the draft's stats can measure you.")
|
||||
.font(.caption)
|
||||
.foregroundStyle(DesignTokens.muted)
|
||||
HStack {
|
||||
Spacer()
|
||||
Button("Cancel", role: .cancel) { dismiss() }
|
||||
.keyboardShortcut(.cancelAction)
|
||||
Button("Import") {
|
||||
answer(origin)
|
||||
dismiss()
|
||||
}
|
||||
.keyboardShortcut(.defaultAction)
|
||||
}
|
||||
}
|
||||
.padding(20)
|
||||
.frame(width: 380)
|
||||
}
|
||||
}
|
||||
|
||||
/// Rail button per the export: 44×44 muted icon, hover wash, and the current
|
||||
/// pane raised as a surface card with a 2px selection bar on the rail's edge.
|
||||
private struct RailButton: View {
|
||||
|
||||
Reference in new issue
Block a user