Add menu option for copying supported images in lightbox (#4614)

This commit is contained in:
Vin Howe 2020-11-02 17:47:46 -07:00 committed by GitHub
parent 2373209834
commit 526ab4fe29
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 52 additions and 15 deletions

View file

@ -376,6 +376,7 @@ export class Lightbox extends React.Component<Props, State> {
alt={i18n('lightboxImageAlt')}
style={styles.img}
src={objectURL}
onContextMenu={this.onContextMenu}
/>
</button>
);
@ -415,6 +416,15 @@ export class Lightbox extends React.Component<Props, State> {
);
};
private readonly onContextMenu = (event: React.MouseEvent<HTMLImageElement>) => {
const { contentType } = this.props;
// These are the only image types supported by Electron's NativeImage
if (contentType !== "image/png" && contentType !== "image/jpg") {
event?.preventDefault();
}
}
private readonly onClose = () => {
const { close } = this.props;
if (!close) {