From 601e8209d8ad53e5f807f4342394896a09fd8196 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 10 Jun 2020 21:48:39 +0100 Subject: [PATCH 1/2] Prioritize text on the clipboard over file Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/views/rooms/SendMessageComposer.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/components/views/rooms/SendMessageComposer.js b/src/components/views/rooms/SendMessageComposer.js index 25ad192ea4..130135f641 100644 --- a/src/components/views/rooms/SendMessageComposer.js +++ b/src/components/views/rooms/SendMessageComposer.js @@ -427,7 +427,9 @@ export default class SendMessageComposer extends React.Component { _onPaste = (event) => { const {clipboardData} = event; - if (clipboardData.files.length) { + // 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 From ed7f4755cc297aafb077cf1cdb09fc17bc5124a9 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 10 Jun 2020 22:05:29 +0100 Subject: [PATCH 2/2] use ButtonEvent instead of MouseEvent | KeyboardEvent for AccessibleButton (make CI happy) Signed-off-by: Michael Telatynski <7t3chguy@gmail.com> --- src/components/structures/UserMenuButton.tsx | 10 +++++----- src/components/views/elements/AccessibleButton.tsx | 4 +++- src/components/views/rooms/RoomTile2.tsx | 8 ++++---- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/structures/UserMenuButton.tsx b/src/components/structures/UserMenuButton.tsx index a8a6535805..41b2c3ab60 100644 --- a/src/components/structures/UserMenuButton.tsx +++ b/src/components/structures/UserMenuButton.tsx @@ -31,7 +31,7 @@ import LogoutDialog from "../views/dialogs/LogoutDialog"; import SettingsStore, {SettingLevel} from "../../settings/SettingsStore"; import {getCustomTheme} from "../../theme"; import {getHostingLink} from "../../utils/HostingLink"; -import AccessibleButton from "../views/elements/AccessibleButton"; +import AccessibleButton, {ButtonEvent} from "../views/elements/AccessibleButton"; interface IProps { } @@ -114,7 +114,7 @@ export default class UserMenuButton extends React.Component { SettingsStore.setValue("theme", null, SettingLevel.ACCOUNT, newTheme); }; - private onSettingsOpen = (ev: React.MouseEvent, tabId: string) => { + private onSettingsOpen = (ev: ButtonEvent, tabId: string) => { ev.preventDefault(); ev.stopPropagation(); @@ -123,7 +123,7 @@ export default class UserMenuButton extends React.Component { this.setState({menuDisplayed: false}); // also close the menu }; - private onShowArchived = (ev: React.MouseEvent) => { + private onShowArchived = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -131,7 +131,7 @@ export default class UserMenuButton extends React.Component { console.log("TODO: Show archived rooms"); }; - private onProvideFeedback = (ev: React.MouseEvent) => { + private onProvideFeedback = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -139,7 +139,7 @@ export default class UserMenuButton extends React.Component { this.setState({menuDisplayed: false}); // also close the menu }; - private onSignOutClick = (ev: React.MouseEvent) => { + private onSignOutClick = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); diff --git a/src/components/views/elements/AccessibleButton.tsx b/src/components/views/elements/AccessibleButton.tsx index 3a542387c5..18dd43ad02 100644 --- a/src/components/views/elements/AccessibleButton.tsx +++ b/src/components/views/elements/AccessibleButton.tsx @@ -19,6 +19,8 @@ import React from 'react'; import {Key} from '../../../Keyboard'; import classnames from 'classnames'; +export type ButtonEvent = React.MouseEvent | React.KeyboardEvent + /** * children: React's magic prop. Represents all children given to the element. * element: (optional) The base element type. "div" by default. @@ -37,7 +39,7 @@ interface IProps extends React.InputHTMLAttributes { tabIndex?: number; disabled?: boolean; className?: string; - onClick?(e?: React.MouseEvent | React.KeyboardEvent): void; + onClick?(e?: ButtonEvent): void; }; interface IAccessibleButtonProps extends React.InputHTMLAttributes { diff --git a/src/components/views/rooms/RoomTile2.tsx b/src/components/views/rooms/RoomTile2.tsx index 7778b5be4b..e8056349e2 100644 --- a/src/components/views/rooms/RoomTile2.tsx +++ b/src/components/views/rooms/RoomTile2.tsx @@ -21,7 +21,7 @@ import React, { createRef } from "react"; import { Room } from "matrix-js-sdk/src/models/room"; import classNames from "classnames"; import { RovingTabIndexWrapper } from "../../../accessibility/RovingTabIndex"; -import AccessibleButton from "../../views/elements/AccessibleButton"; +import AccessibleButton, {ButtonEvent} from "../../views/elements/AccessibleButton"; import RoomAvatar from "../../views/avatars/RoomAvatar"; import dis from '../../../dispatcher/dispatcher'; import { Key } from "../../../Keyboard"; @@ -123,7 +123,7 @@ export default class RoomTile2 extends React.Component { this.setState({generalMenuDisplayed: false}); }; - private onTagRoom = (ev: React.MouseEvent, tagId: TagID) => { + private onTagRoom = (ev: ButtonEvent, tagId: TagID) => { ev.preventDefault(); ev.stopPropagation(); @@ -134,7 +134,7 @@ export default class RoomTile2 extends React.Component { } }; - private onLeaveRoomClick = (ev: React.MouseEvent) => { + private onLeaveRoomClick = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation(); @@ -145,7 +145,7 @@ export default class RoomTile2 extends React.Component { this.setState({generalMenuDisplayed: false}); // hide the menu }; - private onOpenRoomSettings = (ev: React.MouseEvent) => { + private onOpenRoomSettings = (ev: ButtonEvent) => { ev.preventDefault(); ev.stopPropagation();