Files
opencode-manager/frontend/src/lib/domTargets.ts
T
Chris Scott 994a8b82e8 feat(shortcuts): rework shortcut bindings, focus restore, and input guards
Resolve effective bindings from stored prefs plus defaults with leader/direct collision handling and default leader Ctrl+X; let direct actions pass through in terminals and suppress abort while an overlay is open. Add half-page scroll disengage, verified overlay focus restore, and consolidate prompt reset.
2026-10-08 12:40:04 -04:00

26 lines
1012 B
TypeScript

const CONTENT_EDITABLE_VALUES = new Set(['', 'true', 'plaintext-only'])
/**
* Returns true for free-text entry targets: `<input>`, `<textarea>`, and any content-editable
* element (`contenteditable=""`, `"true"`, or `"plaintext-only"`).
*/
export function isTextEntryElement(element: Element): boolean {
if (element instanceof HTMLInputElement || element instanceof HTMLTextAreaElement) return true
if (!(element instanceof HTMLElement)) return false
if (element.isContentEditable) return true
const contentEditable = element.getAttribute('contenteditable')
return contentEditable !== null && CONTENT_EDITABLE_VALUES.has(contentEditable.toLowerCase())
}
/**
* Returns true when the element carries the `data-prompt-input` attribute that marks the chat prompt.
*/
export function isPromptInput(element: Element): boolean {
return element.hasAttribute('data-prompt-input')
}
/**
* Selector matching the chat prompt input.
*/
export const PROMPT_INPUT_SELECTOR = 'textarea[data-prompt-input]'