mirror of https://github.com/vector-im/riot-web
Merge pull request #5389 from matrix-org/t3chguy/fix/15536
Fix onPaste handler to work with copying files from Finderpull/21833/head
commit
9219661d7c
|
@ -514,13 +514,11 @@ export default class SendMessageComposer extends React.Component<IProps> {
|
||||||
|
|
||||||
private onPaste = (event: ClipboardEvent<HTMLDivElement>): boolean => {
|
private onPaste = (event: ClipboardEvent<HTMLDivElement>): boolean => {
|
||||||
const { clipboardData } = event;
|
const { clipboardData } = event;
|
||||||
// Prioritize text on the clipboard over files as Office on macOS puts a bitmap
|
// 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.
|
// in the clipboard as well as the content being copied. Modern versions of Office seem to not do this anymore.
|
||||||
if (clipboardData.files.length && !clipboardData.types.some(t => t === "text/plain")) {
|
// We check text/rtf instead of text/plain as when copy+pasting a file from Finder or Gnome Image Viewer
|
||||||
// This actually not so much for 'files' as such (at time of writing
|
// it puts the filename in as text/plain which we want to ignore.
|
||||||
// neither chrome nor firefox let you paste a plain file copied
|
if (clipboardData.files.length && !clipboardData.types.includes("text/rtf")) {
|
||||||
// from Finder) but more images copied from a different website
|
|
||||||
// / word processor etc.
|
|
||||||
ContentMessages.sharedInstance().sendContentListToRoom(
|
ContentMessages.sharedInstance().sendContentListToRoom(
|
||||||
Array.from(clipboardData.files), this.props.room.roomId, this.context,
|
Array.from(clipboardData.files), this.props.room.roomId, this.context,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue