Skip to content

Commit

Permalink
Merge pull request finos#2109 from NguyenTranHoangSym/SDA-4481
Browse files Browse the repository at this point in the history
SDA-4481: Add Fix to image cannot be copied
  • Loading branch information
NguyenTranHoangSym authored Apr 4, 2024
2 parents 897c617 + 87e27ef commit 668e68e
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/app/context-menu-builder.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { BrowserWindow, clipboard, Menu, MenuItem, shell } from 'electron';
import { apiName } from '../common/api-interface';
import { isDevEnv } from '../common/env';
import { logger } from '../common/logger';
import { ICustomBrowserWindow } from './window-handler';

interface IContextMenuStringTable {
copyMail: () => string;
Expand Down Expand Up @@ -376,12 +378,19 @@ export class ContextMenuBuilder {
* Adds "Copy Image" and "Copy Image URL" items when `src` is valid.
*/
public addImageItems(menu, menuInfo) {
const target = this.getWebContents();
const current = this.getWebContents();
const focusedWindow =
BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
const copyImage = new MenuItem({
label: this.stringTable.copyImage(),
click: (_e) => {
if (focusedWindow && focusedWindow.winName === apiName.mainWindowName) {
current?.send('copy-to-clipboard', menuInfo.srcURL);
} else {
current.copyImageAt(menuInfo.x, menuInfo.y);
}

logger.info('Context-Menu-Builder: Copy Image to clipboard');
target.send('copy-to-clipboard', menuInfo.srcURL);
},
});

Expand Down

0 comments on commit 668e68e

Please sign in to comment.