fix: ctrl+a does not work on Windows in code block (#5692)

This commit is contained in:
Tom Moor
2023-08-14 16:16:12 -04:00
committed by GitHub
parent 9f0534d544
commit 28ae1af2a3
12 changed files with 30 additions and 19 deletions

View File

@@ -1,4 +1,4 @@
import { isMac, isWindows } from "./browser";
import { isMac, isWindows } from "@shared/utils/browser";
export default class Desktop {
/**

View File

@@ -1,44 +0,0 @@
/**
* Returns true if the client is a touch device.
*/
export function isTouchDevice(): boolean {
if (typeof window === "undefined") {
return false;
}
return window.matchMedia?.("(hover: none) and (pointer: coarse)")?.matches;
}
/**
* Returns true if the client is running on a Mac.
*/
export function isMac(): boolean {
return window.navigator.platform === "MacIntel";
}
/**
* Returns true if the client is running on Windows.
*/
export function isWindows(): boolean {
return window.navigator.platform === "Win32";
}
let supportsPassive = false;
try {
const opts = Object.defineProperty({}, "passive", {
get() {
supportsPassive = true;
},
});
// @ts-expect-error ts-migrate(2769) testPassive is not a real event
window.addEventListener("testPassive", null, opts);
// @ts-expect-error ts-migrate(2769) testPassive is not a real event
window.removeEventListener("testPassive", null, opts);
} catch (e) {
// No-op
}
/**
* Returns true if the client supports passive event listeners
*/
export const supportsPassiveListener = supportsPassive;

View File

@@ -1,4 +1,4 @@
import { isMac } from "~/utils/browser";
import { isMac } from "@shared/utils/browser";
export const altDisplay = isMac() ? "⌥" : "Alt";