From aeee293abca62856cacdfdc67a03ed76ebaa81ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Thomas=20M=C3=A4der?= Date: Thu, 4 Jan 2024 16:02:27 +0100 Subject: [PATCH] Fix using copy/paste from a menu in electron. Fixes #12487 (#13220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Contributed on behalf of STMicroelectronics Signed-off-by: Thomas Mäder --- packages/core/src/browser/browser.ts | 7 ++++++- packages/core/src/browser/common-frontend-contribution.ts | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/packages/core/src/browser/browser.ts b/packages/core/src/browser/browser.ts index eace2b5f2670d..c39a76057af7b 100644 --- a/packages/core/src/browser/browser.ts +++ b/packages/core/src/browser/browser.ts @@ -18,6 +18,8 @@ * Licensed under the MIT License. See License.txt in the project root for license information. *--------------------------------------------------------------------------------------------*/ +import { environment } from '../common'; + const userAgent = typeof navigator !== 'undefined' ? navigator.userAgent : ''; export const isIE = (userAgent.indexOf('Trident') >= 0); @@ -31,7 +33,10 @@ export const isChrome = (userAgent.indexOf('Chrome') >= 0); export const isSafari = (userAgent.indexOf('Chrome') === -1) && (userAgent.indexOf('Safari') >= 0); export const isIPad = (userAgent.indexOf('iPad') >= 0); // eslint-disable-next-line @typescript-eslint/no-explicit-any -export const isNative = typeof (window as any).process !== 'undefined'; +/** + * @deprecated us Environment.electron.is + */ +export const isNative = environment.electron.is(); // eslint-disable-next-line @typescript-eslint/no-explicit-any export const isBasicWasmSupported = typeof (window as any).WebAssembly !== 'undefined'; diff --git a/packages/core/src/browser/common-frontend-contribution.ts b/packages/core/src/browser/common-frontend-contribution.ts index dc1532e3315a4..99376fa1467a5 100644 --- a/packages/core/src/browser/common-frontend-contribution.ts +++ b/packages/core/src/browser/common-frontend-contribution.ts @@ -351,12 +351,12 @@ export namespace CommonCommands { }); } -export const supportCut = browser.isNative || document.queryCommandSupported('cut'); -export const supportCopy = browser.isNative || document.queryCommandSupported('copy'); +export const supportCut = environment.electron.is() || document.queryCommandSupported('cut'); +export const supportCopy = environment.electron.is() || document.queryCommandSupported('copy'); // Chrome incorrectly returns true for document.queryCommandSupported('paste') // when the paste feature is available but the calling script has insufficient // privileges to actually perform the action -export const supportPaste = browser.isNative || (!browser.isChrome && document.queryCommandSupported('paste')); +export const supportPaste = environment.electron.is() || (!browser.isChrome && document.queryCommandSupported('paste')); export const RECENT_COMMANDS_STORAGE_KEY = 'commands';