mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 13:19:03 +00:00
#204 empty hotkeys won't trigger
This commit is contained in:
parent
c5c02bc7e7
commit
bc46ac39b0
@ -37,6 +37,8 @@ npm link
|
|||||||
notion-enhancer apply -y
|
notion-enhancer apply -y
|
||||||
```
|
```
|
||||||
|
|
||||||
|
to update the dev build, go into the downloaded folder and run `git pull`. (make sure any work-in-progress themes etc. are copied somewhere else safely first.)
|
||||||
|
|
||||||
to remove the dev build, go into the downloaded folder and run:
|
to remove the dev build, go into the downloaded folder and run:
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
|
@ -22,55 +22,58 @@ module.exports = (store, __exports) => {
|
|||||||
// additional hotkeys
|
// additional hotkeys
|
||||||
if (event.key === 'F5') location.reload();
|
if (event.key === 'F5') location.reload();
|
||||||
// open menu on hotkey toggle
|
// open menu on hotkey toggle
|
||||||
const hotkey = toKeyEvent(store().menu_toggle);
|
if (store().menu_toggle) {
|
||||||
let triggered = true;
|
const hotkey = toKeyEvent(store().menu_toggle);
|
||||||
for (let prop in hotkey)
|
|
||||||
if (
|
|
||||||
hotkey[prop] !== event[prop] &&
|
|
||||||
!(prop === 'key' && event[prop] === 'Dead')
|
|
||||||
)
|
|
||||||
triggered = false;
|
|
||||||
if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
|
|
||||||
if (tabsEnabled) {
|
|
||||||
// switch between tabs via key modifier
|
|
||||||
const select_tab_modifier = toKeyEvent(
|
|
||||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').select_modifier
|
|
||||||
);
|
|
||||||
let triggered = true;
|
let triggered = true;
|
||||||
for (let prop in select_tab_modifier)
|
for (let prop in hotkey)
|
||||||
if (select_tab_modifier[prop] !== event[prop]) triggered = false;
|
if (
|
||||||
if (
|
hotkey[prop] !== event[prop] &&
|
||||||
triggered &&
|
!(prop === 'key' && event[prop] === 'Dead')
|
||||||
[
|
)
|
||||||
'1',
|
triggered = false;
|
||||||
'2',
|
if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
|
||||||
'3',
|
}
|
||||||
'4',
|
if (tabsEnabled) {
|
||||||
'5',
|
const tabStore = () => store('e1692c29-475e-437b-b7ff-3eee872e1a42');
|
||||||
'6',
|
if (tabStore().select_modifier) {
|
||||||
'7',
|
// switch between tabs via key modifier
|
||||||
'8',
|
const select_tab_modifier = toKeyEvent(select_tab_modifier);
|
||||||
'9',
|
let triggered = true;
|
||||||
'ArrowRight',
|
for (let prop in select_tab_modifier)
|
||||||
'ArrowLeft',
|
if (select_tab_modifier[prop] !== event[prop]) triggered = false;
|
||||||
].includes(event.key)
|
if (
|
||||||
)
|
triggered &&
|
||||||
electron.ipcRenderer.sendToHost('enhancer:select-tab', event.key);
|
[
|
||||||
// create/close tab keybindings
|
'1',
|
||||||
const new_tab_keybinding = toKeyEvent(
|
'2',
|
||||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').new_tab
|
'3',
|
||||||
);
|
'4',
|
||||||
triggered = true;
|
'5',
|
||||||
for (let prop in new_tab_keybinding)
|
'6',
|
||||||
if (new_tab_keybinding[prop] !== event[prop]) triggered = false;
|
'7',
|
||||||
if (triggered) electron.ipcRenderer.sendToHost('enhancer:new-tab');
|
'8',
|
||||||
const close_tab_keybinding = toKeyEvent(
|
'9',
|
||||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').close_tab
|
'ArrowRight',
|
||||||
);
|
'ArrowLeft',
|
||||||
triggered = true;
|
].includes(event.key)
|
||||||
for (let prop in close_tab_keybinding)
|
)
|
||||||
if (close_tab_keybinding[prop] !== event[prop]) triggered = false;
|
electron.ipcRenderer.sendToHost('enhancer:select-tab', event.key);
|
||||||
if (triggered) electron.ipcRenderer.sendToHost('enhancer:close-tab');
|
}
|
||||||
|
if (tabStore().new_tab) {
|
||||||
|
// create/close tab keybindings
|
||||||
|
const new_tab_keybinding = toKeyEvent(tabStore().new_tab);
|
||||||
|
let triggered = true;
|
||||||
|
for (let prop in new_tab_keybinding)
|
||||||
|
if (new_tab_keybinding[prop] !== event[prop]) triggered = false;
|
||||||
|
if (triggered) electron.ipcRenderer.sendToHost('enhancer:new-tab');
|
||||||
|
}
|
||||||
|
if (tabStore().close_tab) {
|
||||||
|
const close_tab_keybinding = toKeyEvent(tabStore().close_tab);
|
||||||
|
let triggered = true;
|
||||||
|
for (let prop in close_tab_keybinding)
|
||||||
|
if (close_tab_keybinding[prop] !== event[prop]) triggered = false;
|
||||||
|
if (triggered) electron.ipcRenderer.sendToHost('enhancer:close-tab');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -145,16 +145,18 @@ window['__start'] = async () => {
|
|||||||
)
|
)
|
||||||
$popup.classList.remove('visible');
|
$popup.classList.remove('visible');
|
||||||
// close window on hotkey toggle
|
// close window on hotkey toggle
|
||||||
const hotkey = toKeyEvent(coreStore().menu_toggle);
|
if (coreStore().menu_toggle) {
|
||||||
let triggered = true;
|
const hotkey = toKeyEvent(coreStore().menu_toggle);
|
||||||
for (let prop in hotkey)
|
let triggered = true;
|
||||||
if (
|
for (let prop in hotkey)
|
||||||
hotkey[prop] !== event[prop] &&
|
if (
|
||||||
!(prop === 'key' && event[prop] === 'Dead')
|
hotkey[prop] !== event[prop] &&
|
||||||
)
|
!(prop === 'key' && event[prop] === 'Dead')
|
||||||
triggered = false;
|
)
|
||||||
if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w'))
|
triggered = false;
|
||||||
electron.remote.getCurrentWindow().close();
|
if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w'))
|
||||||
|
electron.remote.getCurrentWindow().close();
|
||||||
|
}
|
||||||
// focus search
|
// focus search
|
||||||
const meta =
|
const meta =
|
||||||
!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;
|
!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;
|
||||||
|
@ -1010,19 +1010,6 @@ module.exports = (store, __exports) => {
|
|||||||
document.body.className = `notion-${theme}-theme`;
|
document.body.className = `notion-${theme}-theme`;
|
||||||
});
|
});
|
||||||
|
|
||||||
// open menu on hotkey toggle
|
|
||||||
document.addEventListener('keyup', (event) => {
|
|
||||||
const hotkey = toKeyEvent(store().menu_toggle);
|
|
||||||
let triggered = true;
|
|
||||||
for (let prop in hotkey)
|
|
||||||
if (
|
|
||||||
hotkey[prop] !== event[prop] &&
|
|
||||||
!(prop === 'key' && event[prop] === 'Dead')
|
|
||||||
)
|
|
||||||
triggered = false;
|
|
||||||
if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
|
|
||||||
});
|
|
||||||
|
|
||||||
const parsed = url.parse(window.location.href, true),
|
const parsed = url.parse(window.location.href, true),
|
||||||
notionUrl =
|
notionUrl =
|
||||||
parsed.query.path ||
|
parsed.query.path ||
|
||||||
|
@ -246,11 +246,13 @@ module.exports = (store, __exports) => {
|
|||||||
else showWindows(windows);
|
else showWindows(windows);
|
||||||
}
|
}
|
||||||
tray.on('click', toggleWindows);
|
tray.on('click', toggleWindows);
|
||||||
electron.globalShortcut.register(store().hotkey, () => {
|
if (store().hotkey) {
|
||||||
const windows = getAllWindows();
|
electron.globalShortcut.register(store().hotkey, () => {
|
||||||
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
const windows = getAllWindows();
|
||||||
hideWindows(windows);
|
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
||||||
else showWindows(windows);
|
hideWindows(windows);
|
||||||
});
|
else showWindows(windows);
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user