Paste and drop images into every box that talks to an agent
This commit is contained in:
@@ -112,7 +112,7 @@ private final class CardModel {
|
||||
}
|
||||
|
||||
var hasImages: Bool {
|
||||
!store.images.images(key).isEmpty
|
||||
store.images.has(key)
|
||||
}
|
||||
|
||||
var typed: String {
|
||||
@@ -494,7 +494,6 @@ private struct TextEntry: View {
|
||||
@Environment(\.paneAccent) private var accent
|
||||
@FocusState private var editing: Bool
|
||||
@ViewState private var hover = false
|
||||
@ViewState private var targeted = false
|
||||
|
||||
var body: some View {
|
||||
let id = model.item.id
|
||||
@@ -514,7 +513,6 @@ private struct TextEntry: View {
|
||||
.writingToolsBehavior(.disabled)
|
||||
.focused($editing)
|
||||
.disabled(model.busy)
|
||||
.focusedValue(\.composer, ComposerTarget(paste: { pb in store.images.add(key, pasteboard: pb, overlays) }))
|
||||
.onKeyPress(.return, phases: .down) { press in
|
||||
let marked = (NSApp.keyWindow?.firstResponder as? NSTextView)?.hasMarkedText() ?? false
|
||||
if press.modifiers.contains(.shift) || marked {
|
||||
@@ -536,16 +534,8 @@ private struct TextEntry: View {
|
||||
.allowsHitTesting(false)
|
||||
}
|
||||
}
|
||||
.overlay(RoundedRectangle(cornerRadius: 6).stroke(targeted || editing ? Palette.accent : Palette.border))
|
||||
.overlay {
|
||||
Color.clear
|
||||
.contentShape(Rectangle())
|
||||
.allowsHitTesting(false)
|
||||
.onDrop(of: [.image, .fileURL], isTargeted: $targeted) { providers in
|
||||
store.images.add(key, providers: providers, overlays)
|
||||
return true
|
||||
}
|
||||
}
|
||||
.overlay(RoundedRectangle(cornerRadius: 6).stroke(editing ? Palette.accent : Palette.border))
|
||||
.imageInput(key)
|
||||
}
|
||||
.onChange(of: editing) {
|
||||
if !editing {
|
||||
|
||||
Reference in New Issue
Block a user