Paste files and images into the chat composer on macOS
Native hosts reported clipboard-file paste as unsupported, and Flutter's Clipboard carries text only, so Cmd+V of a Finder file or a screenshot in the macOS app pasted nothing (or the file name). The macOS Runner now answers a pipelines/clipboard_files channel with the pasteboard's file URLs, else its image as PNG; the composer's Cmd+V reads it and attaches the files, falling back to the pasteboard text when there are none. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
import 'chat_clipboard_paste.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
/// Native fallback for clipboard-file paste.
|
||||
import 'chat_clipboard_paste.dart';
|
||||
import 'chat_clipboard_paste_native.dart';
|
||||
|
||||
/// Native clipboard-file paste.
|
||||
///
|
||||
/// The composer keeps the host field's own text paste on every platform; this
|
||||
/// slice observes clipboard files on web only. A non-web host reports that
|
||||
/// missing capability rather than pretending no paste happened.
|
||||
/// macOS reads the pasteboard through its Runner
|
||||
/// ([nativeChatClipboardPaste]). Other native hosts have no pasteboard reader
|
||||
/// yet: they report that missing capability rather than pretending no paste
|
||||
/// happened, and the composer keeps the host field's own text paste.
|
||||
const String chatClipboardPasteUnsupportedMessage =
|
||||
'Pasting files is not supported on this platform yet.';
|
||||
|
||||
ChatClipboardPaste get hostChatClipboardPaste =>
|
||||
const ChatClipboardPaste.unsupported(chatClipboardPasteUnsupportedMessage);
|
||||
chatHostReadsClipboardFiles(defaultTargetPlatform)
|
||||
? nativeChatClipboardPaste()
|
||||
: const ChatClipboardPaste.unsupported(
|
||||
chatClipboardPasteUnsupportedMessage,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user