feat: singlecharacter shortcuts

This commit is contained in:
Andrew Bastin
2021-08-07 18:42:15 +05:30
parent 3d963a7719
commit 93dfed74f8
4 changed files with 94 additions and 38 deletions

19
helpers/utils/dom.ts Normal file
View File

@@ -0,0 +1,19 @@
export function isDOMElement(el: any): el is HTMLElement {
return !!el && (el instanceof Element || el instanceof HTMLElement)
}
export function isTypableElement(el: HTMLElement): boolean {
// If content editable, then it is editable
if (el.isContentEditable) return true
// If element is an input and the input is enabled, then it is typable
if (el.tagName === "INPUT") {
return !(el as HTMLInputElement).disabled
}
// If element is a textarea and the input is enabled, then it is typable
if (el.tagName === "TEXTAREA") {
return !(el as HTMLTextAreaElement).disabled
}
return false
}