diff options
| author | Maze Winther <mazewinther@gmail.com> | 2025-07-18 11:37:48 +0200 |
|---|---|---|
| committer | Maze Winther <mazewinther@gmail.com> | 2025-07-18 11:37:48 +0200 |
| commit | 74e7d427aaed3517ce578c2192f783dacffc02fc (patch) | |
| tree | c6ec27070940778e64ca3ad50cd937227f87f3ac /apps/web/src/lib | |
| parent | c4e6a9a45ab0f0afdde4f0c9991e39cd5d6205d0 (diff) | |
| parent | 23001f8442e60999e34c0d6c348fecf0867b6cad (diff) | |
| download | opencut-74e7d427aaed3517ce578c2192f783dacffc02fc.tar.gz | |
Merge branch 'feat/shortcut-actions' into staging
Diffstat (limited to 'apps/web/src/lib')
| -rw-r--r-- | apps/web/src/lib/utils.ts | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index fd47cc13..8d2ee03a 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -44,6 +44,25 @@ export function generateUUID(): string { ); } +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; +} export function isAppleDevice() { return /(Mac|iPhone|iPod|iPad)/i.test(navigator.platform); } |
