mirror of
https://github.com/Syngnat/GoNavi.git
synced 2026-06-11 09:00:00 +08:00
- 放行编辑器和输入控件内的 Escape 按键事件 - 保留 macOS 原生全屏下普通区域的 Escape 抑制逻辑 - 补充 Mac 窗口快捷键回归测试 Refs #433
47 lines
1.3 KiB
TypeScript
47 lines
1.3 KiB
TypeScript
export const getMacNativeTitlebarPaddingLeft = (uiScale: number, enabled: boolean): number => {
|
|
if (!enabled) {
|
|
return Math.max(12, Math.round(16 * uiScale));
|
|
}
|
|
return Math.max(88, Math.round(96 * uiScale));
|
|
};
|
|
|
|
export const getMacNativeTitlebarPaddingRight = (uiScale: number, enabled: boolean): number => {
|
|
if (!enabled) {
|
|
return 0;
|
|
}
|
|
return Math.max(12, Math.round(16 * uiScale));
|
|
};
|
|
|
|
export const shouldHandleMacNativeFullscreenShortcut = (
|
|
isMacRuntime: boolean,
|
|
useNativeMacWindowControls: boolean,
|
|
event: Pick<KeyboardEvent, 'ctrlKey' | 'metaKey' | 'altKey' | 'key'>,
|
|
): boolean => {
|
|
if (!isMacRuntime || !useNativeMacWindowControls) {
|
|
return false;
|
|
}
|
|
if (!event.ctrlKey || !event.metaKey || event.altKey) {
|
|
return false;
|
|
}
|
|
return String(event.key || '').toLowerCase() === 'f';
|
|
};
|
|
|
|
export const shouldSuppressMacNativeEscapeExit = (
|
|
isMacRuntime: boolean,
|
|
useNativeMacWindowControls: boolean,
|
|
isFullscreen: boolean,
|
|
event: Pick<KeyboardEvent, 'key' | 'defaultPrevented'>,
|
|
options?: { isEditableTarget?: boolean },
|
|
): boolean => {
|
|
if (!isMacRuntime || !useNativeMacWindowControls || !isFullscreen) {
|
|
return false;
|
|
}
|
|
if (options?.isEditableTarget) {
|
|
return false;
|
|
}
|
|
if (event.defaultPrevented) {
|
|
return false;
|
|
}
|
|
return String(event.key || '') === 'Escape';
|
|
};
|