Fix keyboard shortcuts to use Control on Windows and Linux (#3620)

* Fix keyboard shortcuts to use Control instead of Meta on Windows and Linux

* Convert more tests to use Playwright built-in
This commit is contained in:
Jonathan Tran
2024-08-22 19:13:27 -04:00
committed by GitHub
parent e624c9b124
commit acbe92d717
14 changed files with 92 additions and 112 deletions

View File

@ -1,6 +1,7 @@
import { SourceRange } from '../lang/wasm'
import { v4 } from 'uuid'
import { isDesktop } from './isDesktop'
export const uuidv4 = v4
@ -126,6 +127,41 @@ export function getNormalisedCoordinates({
}
}
// TODO: Remove the empty platform type.
export type Platform = 'macos' | 'windows' | 'linux' | ''
export function platform(): Platform {
if (isDesktop()) {
const platform = window.electron.platform ?? ''
// https://nodejs.org/api/process.html#processplatform
switch (platform) {
case 'darwin':
return 'macos'
case 'win32':
return 'windows'
// We don't currently care to distinguish between these.
case 'android':
case 'freebsd':
case 'linux':
case 'openbsd':
case 'sunos':
return 'linux'
default:
console.error('Unknown platform:', platform)
return ''
}
}
if (navigator.userAgent.indexOf('Mac') !== -1) {
return 'macos'
} else if (navigator.userAgent.indexOf('Win') !== -1) {
return 'windows'
} else if (navigator.userAgent.indexOf('Linux') !== -1) {
return 'linux'
}
console.error('Unknown platform userAgent:', navigator.userAgent)
return ''
}
export function isReducedMotion(): boolean {
return (
typeof window !== 'undefined' &&