The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | const EDITABLE_SELECTOR = [ |
| 2 | "input", |
| 3 | "textarea", |
| 4 | "select", |
| 5 | '[contenteditable=""]', |
| 6 | '[contenteditable="true"]', |
| 7 | '[contenteditable="plaintext-only"]', |
| 8 | '[role="textbox"]', |
| 9 | ].join(","); |
| 10 | |
| 11 | /** Includes focused descendants of open shadow roots, whose key events target the host. */ |
| 12 | export function isEditableFocused(target: EventTarget | null = document.activeElement): boolean { |
| 13 | let element = target instanceof Element ? target : null; |
| 14 | while (element?.shadowRoot?.activeElement) element = element.shadowRoot.activeElement; |
| 15 | return element !== null && element.closest(EDITABLE_SELECTOR) !== null; |
| 16 | } |