-
-
Notifications
You must be signed in to change notification settings - Fork 829
Fix onPaste handler to work with copying files from Finder #5389
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -445,13 +445,11 @@ export default class SendMessageComposer extends React.Component { | |
|
||
_onPaste = (event) => { | ||
const {clipboardData} = event; | ||
// Prioritize text on the clipboard over files as Office on macOS puts a bitmap | ||
// in the clipboard as well as the content being copied. | ||
if (clipboardData.files.length && !clipboardData.types.some(t => t === "text/plain")) { | ||
// This actually not so much for 'files' as such (at time of writing | ||
// neither chrome nor firefox let you paste a plain file copied | ||
// from Finder) but more images copied from a different website | ||
// / word processor etc. | ||
// Prioritize text on the clipboard over files if RTF is present as Office on macOS puts a bitmap | ||
// in the clipboard as well as the content being copied. Modern versions of Office seem to not do this anymore. | ||
// We check text/rtf instead of text/plain as when copy+pasting a file from Finder it puts the filename | ||
// in as text/plain which we want to ignore. | ||
if (clipboardData.files.length && !clipboardData.types.includes("text/rtf")) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Surely we should still be falling back to text/plain too? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as the comment says, this heuristic is based on rtf because Finder puts both the File and There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. but we're not dealing with just Apple here, this is also a thing for Windows and Linux, though the Office issue in particular is actually documented. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The behaviour should be to use the file 1st except in the case of Office/other known faulty things to enable copy pasting files where an annotation of the file name is also attached. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, and the point I'm trying to make is that not all of those things publish There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can you give an example of one so I can see how else to work around it? Do you have any suggestions on how to work around them whilst fixing the regression of breaking copy paste from Finder? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Based on your original report |
||
ContentMessages.sharedInstance().sendContentListToRoom( | ||
Array.from(clipboardData.files), this.props.room.roomId, this.context, | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How modern is modern? As recently as this summer it was still broken.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No idea, but this is still safe from it as per your comment on the original issue that Office version also put text/rtf in it