Skip to content

Commit

Permalink
Fix using copy/paste from a menu in electron. Fixes eclipse-theia#12487
Browse files Browse the repository at this point in the history
… (eclipse-theia#13220)

Contributed on behalf of STMicroelectronics

Signed-off-by: Thomas Mäder <[email protected]>
  • Loading branch information
tsmaeder authored Jan 4, 2024
1 parent 72421be commit aeee293
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
7 changes: 6 additions & 1 deletion packages/core/src/browser/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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';

Expand Down
6 changes: 3 additions & 3 deletions packages/core/src/browser/common-frontend-contribution.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down

0 comments on commit aeee293

Please sign in to comment.