(id: string)
| 79 | } |
| 80 | |
| 81 | export const focusTerminalById = (id: string) => { |
| 82 | const wrapper = document.getElementById(`terminal-wrapper-${id}`) |
| 83 | const terminal = wrapper?.querySelector('[data-component="terminal"]') |
| 84 | if (!(terminal instanceof HTMLElement)) return false |
| 85 | |
| 86 | const textarea = terminal.querySelector("textarea") |
| 87 | if (textarea instanceof HTMLTextAreaElement) { |
| 88 | textarea.focus() |
| 89 | return true |
| 90 | } |
| 91 | |
| 92 | terminal.focus() |
| 93 | terminal.dispatchEvent( |
| 94 | typeof PointerEvent === "function" |
| 95 | ? new PointerEvent("pointerdown", { bubbles: true, cancelable: true }) |
| 96 | : new MouseEvent("pointerdown", { bubbles: true, cancelable: true }), |
| 97 | ) |
| 98 | return true |
| 99 | } |
| 100 | |
| 101 | const skip = new Set(["Alt", "Control", "Meta", "Shift"]) |
| 102 |
no outgoing calls
no test coverage detected