Skip to content
Source
Sign inSign up

previewFocus.ts

7 lines345 Bytes

1export function isPreviewFocused(): boolean {
2 const activeElement = document.activeElement;
3 if (!(activeElement instanceof HTMLElement)) return false;
4 if (!activeElement.isConnected) return false;
5 if (activeElement.tagName.toLowerCase() === "webview") return true;
6 return activeElement.closest("[data-preview-panel-mode]") !== null;
7}