mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 05:29:02 +00:00
remove hasFocus checks: not all events were being responded to
This commit is contained in:
parent
d984c8bc36
commit
e4187700b2
File diff suppressed because one or more lines are too long
@ -29,9 +29,7 @@ export const whenReady = (selectors = []) => {
|
|||||||
const onLoad = () => {
|
const onLoad = () => {
|
||||||
const interval = setInterval(isReady, 100);
|
const interval = setInterval(isReady, 100);
|
||||||
function isReady() {
|
function isReady() {
|
||||||
const ready =
|
const ready = selectors.every((selector) => document.querySelector(selector));
|
||||||
document.hasFocus() &&
|
|
||||||
selectors.every((selector) => document.querySelector(selector));
|
|
||||||
if (!ready) return;
|
if (!ready) return;
|
||||||
clearInterval(interval);
|
clearInterval(interval);
|
||||||
res(true);
|
res(true);
|
||||||
@ -170,7 +168,7 @@ export const readFromClipboard = () => {
|
|||||||
|
|
||||||
const triggerHotkeyListener = (event, hotkey) => {
|
const triggerHotkeyListener = (event, hotkey) => {
|
||||||
const inInput = document.activeElement.nodeName === 'INPUT' && !hotkey.listenInInput;
|
const inInput = document.activeElement.nodeName === 'INPUT' && !hotkey.listenInInput;
|
||||||
if (inInput || !document.hasFocus()) return;
|
if (inInput) return;
|
||||||
const pressed = hotkey.keys.every((key) => {
|
const pressed = hotkey.keys.every((key) => {
|
||||||
key = key.toLowerCase();
|
key = key.toLowerCase();
|
||||||
const modifiers = {
|
const modifiers = {
|
||||||
@ -262,7 +260,7 @@ export const addDocumentObserver = (callback, selectors = []) => {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
_documentObserver = new MutationObserver((list, observer) => {
|
_documentObserver = new MutationObserver((list, observer) => {
|
||||||
if (!_documentObserverEvents.length && document.hasFocus())
|
if (!_documentObserverEvents.length)
|
||||||
requestIdleCallback(() => handle(_documentObserverEvents));
|
requestIdleCallback(() => handle(_documentObserverEvents));
|
||||||
_documentObserverEvents.push(...list);
|
_documentObserverEvents.push(...list);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user