Chore/slice workflow utils (#17730)

This commit is contained in:
zxhlyh
2025-04-10 10:03:19 +08:00
committed by GitHub
parent 9d5a0fdd8a
commit 30f7118c7a
19 changed files with 1215 additions and 1081 deletions

View File

@@ -0,0 +1,35 @@
export const isMac = () => {
return navigator.userAgent.toUpperCase().includes('MAC')
}
const specialKeysNameMap: Record<string, string | undefined> = {
ctrl: '⌘',
alt: '⌥',
shift: '⇧',
}
export const getKeyboardKeyNameBySystem = (key: string) => {
if (isMac())
return specialKeysNameMap[key] || key
return key
}
const specialKeysCodeMap: Record<string, string | undefined> = {
ctrl: 'meta',
}
export const getKeyboardKeyCodeBySystem = (key: string) => {
if (isMac())
return specialKeysCodeMap[key] || key
return key
}
export const isEventTargetInputArea = (target: HTMLElement) => {
if (target.tagName === 'INPUT' || target.tagName === 'TEXTAREA')
return true
if (target.contentEditable === 'true')
return true
}