Open History to see the last commit
1const EDITABLE_SELECTOR = [
2 "input",
3 "textarea",
4 "select",
5 '[contenteditable=""]',
6 '[contenteditable="true"]',
7 '[contenteditable="plaintext-only"]',
8 '[role="textbox"]',
9].join(",");
10
11/**
12 * Whether a text-editing element owns the keyboard. Shortcuts that share
13 * their chord with native editing (mod+z) must yield when this is true.
14 */
15export function isEditableFocused(target: EventTarget | null = document.activeElement): boolean {
16 return target instanceof Element && target.closest(EDITABLE_SELECTOR) !== null;
17}