mirror of
https://github.com/finos/SymphonyElectron.git
synced 2024-12-26 08:51:22 -06:00
Merge pull request #2109 from NguyenTranHoangSym/SDA-4481
SDA-4481: Add Fix to image cannot be copied
This commit is contained in:
commit
668e68ec90
@ -1,6 +1,8 @@
|
|||||||
import { BrowserWindow, clipboard, Menu, MenuItem, shell } from 'electron';
|
import { BrowserWindow, clipboard, Menu, MenuItem, shell } from 'electron';
|
||||||
|
import { apiName } from '../common/api-interface';
|
||||||
import { isDevEnv } from '../common/env';
|
import { isDevEnv } from '../common/env';
|
||||||
import { logger } from '../common/logger';
|
import { logger } from '../common/logger';
|
||||||
|
import { ICustomBrowserWindow } from './window-handler';
|
||||||
|
|
||||||
interface IContextMenuStringTable {
|
interface IContextMenuStringTable {
|
||||||
copyMail: () => string;
|
copyMail: () => string;
|
||||||
@ -376,12 +378,19 @@ export class ContextMenuBuilder {
|
|||||||
* Adds "Copy Image" and "Copy Image URL" items when `src` is valid.
|
* Adds "Copy Image" and "Copy Image URL" items when `src` is valid.
|
||||||
*/
|
*/
|
||||||
public addImageItems(menu, menuInfo) {
|
public addImageItems(menu, menuInfo) {
|
||||||
const target = this.getWebContents();
|
const current = this.getWebContents();
|
||||||
|
const focusedWindow =
|
||||||
|
BrowserWindow.getFocusedWindow() as ICustomBrowserWindow;
|
||||||
const copyImage = new MenuItem({
|
const copyImage = new MenuItem({
|
||||||
label: this.stringTable.copyImage(),
|
label: this.stringTable.copyImage(),
|
||||||
click: (_e) => {
|
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');
|
logger.info('Context-Menu-Builder: Copy Image to clipboard');
|
||||||
target.send('copy-to-clipboard', menuInfo.srcURL);
|
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user