Enable the message right-click context menu in the browser (#8336)
* Enable the message right-click context menu in the browser Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Move `getSelectedText()` to `strings.ts` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com> * Move `canCancel()` to `EventUtils.ts` Signed-off-by: Šimon Brandner <simon.bra.ag@gmail.com>
This commit is contained in:
parent
1afecc474f
commit
11e0a3a8fa
5 changed files with 32 additions and 15 deletions
|
@ -37,7 +37,7 @@ import { ReadPinsEventId } from "../right_panel/types";
|
|||
import { Action } from "../../../dispatcher/actions";
|
||||
import { RoomPermalinkCreator } from '../../../utils/permalinks/Permalinks';
|
||||
import { ButtonEvent } from '../elements/AccessibleButton';
|
||||
import { copyPlaintext } from '../../../utils/strings';
|
||||
import { copyPlaintext, getSelectedText } from '../../../utils/strings';
|
||||
import ContextMenu, { toRightOf } from '../../structures/ContextMenu';
|
||||
import ReactionPicker from '../emojipicker/ReactionPicker';
|
||||
import ViewSource from '../../structures/ViewSource';
|
||||
|
@ -54,10 +54,6 @@ import { OpenForwardDialogPayload } from "../../../dispatcher/payloads/OpenForwa
|
|||
import { OpenReportEventDialogPayload } from "../../../dispatcher/payloads/OpenReportEventDialogPayload";
|
||||
import { createMapSiteLink } from '../../../utils/location';
|
||||
|
||||
export function canCancel(status: EventStatus): boolean {
|
||||
return status === EventStatus.QUEUED || status === EventStatus.NOT_SENT || status === EventStatus.ENCRYPTING;
|
||||
}
|
||||
|
||||
export interface IEventTileOps {
|
||||
isWidgetHidden(): boolean;
|
||||
unhideWidget(): void;
|
||||
|
@ -263,7 +259,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
};
|
||||
|
||||
private onCopyClick = (): void => {
|
||||
copyPlaintext(this.getSelectedText());
|
||||
copyPlaintext(getSelectedText());
|
||||
this.closeMenu();
|
||||
};
|
||||
|
||||
|
@ -310,10 +306,6 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
});
|
||||
}
|
||||
|
||||
private getSelectedText(): string {
|
||||
return window.getSelection().toString();
|
||||
}
|
||||
|
||||
private getPermalink(): string {
|
||||
if (!this.props.permalinkCreator) return;
|
||||
return this.props.permalinkCreator.forEvent(this.props.mxEvent.getId());
|
||||
|
@ -539,7 +531,7 @@ export default class MessageContextMenu extends React.Component<IProps, IState>
|
|||
);
|
||||
}
|
||||
|
||||
if (rightClick && this.getSelectedText()) {
|
||||
if (rightClick && getSelectedText()) {
|
||||
copyButton = (
|
||||
<IconizedContextMenuOption
|
||||
iconClassName="mx_MessageContextMenu_iconCopy"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue