From d7967882a06a34224138a56c42cbe394df3ff70f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?marcin=20miko=C5=82ajczak?= Date: Fri, 29 Jul 2022 22:03:00 +0200 Subject: [PATCH] Allow to paste attachments in chat box MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: marcin mikołajczak --- app/soapbox/features/chats/components/chat-box.tsx | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/app/soapbox/features/chats/components/chat-box.tsx b/app/soapbox/features/chats/components/chat-box.tsx index 869764961..66371bc8d 100644 --- a/app/soapbox/features/chats/components/chat-box.tsx +++ b/app/soapbox/features/chats/components/chat-box.tsx @@ -97,6 +97,12 @@ const ChatBox: React.FC = ({ chatId, onSetInputRef, autosize }) => { setContent(e.target.value); }; + const handlePaste: React.ClipboardEventHandler = (e) => { + if (!canSubmit() && e.clipboardData && e.clipboardData.files.length === 1) { + handleFiles(e.clipboardData.files); + } + }; + const markRead = () => { dispatch(markChatRead(chatId)); }; @@ -182,6 +188,7 @@ const ChatBox: React.FC = ({ chatId, onSetInputRef, autosize }) => { placeholder={intl.formatMessage(messages.placeholder)} onKeyDown={handleKeyDown} onChange={handleContentChange} + onPaste={handlePaste} value={content} ref={setInputRef} />