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
|
||||
```
|
||||
|
||||
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:
|
||||
|
||||
```sh
|
||||
|
@ -22,55 +22,58 @@ module.exports = (store, __exports) => {
|
||||
// additional hotkeys
|
||||
if (event.key === 'F5') location.reload();
|
||||
// open menu on hotkey toggle
|
||||
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');
|
||||
if (tabsEnabled) {
|
||||
// switch between tabs via key modifier
|
||||
const select_tab_modifier = toKeyEvent(
|
||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').select_modifier
|
||||
);
|
||||
if (store().menu_toggle) {
|
||||
const hotkey = toKeyEvent(store().menu_toggle);
|
||||
let triggered = true;
|
||||
for (let prop in select_tab_modifier)
|
||||
if (select_tab_modifier[prop] !== event[prop]) triggered = false;
|
||||
if (
|
||||
triggered &&
|
||||
[
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'ArrowRight',
|
||||
'ArrowLeft',
|
||||
].includes(event.key)
|
||||
)
|
||||
electron.ipcRenderer.sendToHost('enhancer:select-tab', event.key);
|
||||
// create/close tab keybindings
|
||||
const new_tab_keybinding = toKeyEvent(
|
||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').new_tab
|
||||
);
|
||||
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');
|
||||
const close_tab_keybinding = toKeyEvent(
|
||||
store('e1692c29-475e-437b-b7ff-3eee872e1a42').close_tab
|
||||
);
|
||||
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');
|
||||
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) {
|
||||
const tabStore = () => store('e1692c29-475e-437b-b7ff-3eee872e1a42');
|
||||
if (tabStore().select_modifier) {
|
||||
// switch between tabs via key modifier
|
||||
const select_tab_modifier = toKeyEvent(select_tab_modifier);
|
||||
let triggered = true;
|
||||
for (let prop in select_tab_modifier)
|
||||
if (select_tab_modifier[prop] !== event[prop]) triggered = false;
|
||||
if (
|
||||
triggered &&
|
||||
[
|
||||
'1',
|
||||
'2',
|
||||
'3',
|
||||
'4',
|
||||
'5',
|
||||
'6',
|
||||
'7',
|
||||
'8',
|
||||
'9',
|
||||
'ArrowRight',
|
||||
'ArrowLeft',
|
||||
].includes(event.key)
|
||||
)
|
||||
electron.ipcRenderer.sendToHost('enhancer:select-tab', event.key);
|
||||
}
|
||||
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');
|
||||
// close window on hotkey toggle
|
||||
const hotkey = toKeyEvent(coreStore().menu_toggle);
|
||||
let triggered = true;
|
||||
for (let prop in hotkey)
|
||||
if (
|
||||
hotkey[prop] !== event[prop] &&
|
||||
!(prop === 'key' && event[prop] === 'Dead')
|
||||
)
|
||||
triggered = false;
|
||||
if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w'))
|
||||
electron.remote.getCurrentWindow().close();
|
||||
if (coreStore().menu_toggle) {
|
||||
const hotkey = toKeyEvent(coreStore().menu_toggle);
|
||||
let triggered = true;
|
||||
for (let prop in hotkey)
|
||||
if (
|
||||
hotkey[prop] !== event[prop] &&
|
||||
!(prop === 'key' && event[prop] === 'Dead')
|
||||
)
|
||||
triggered = false;
|
||||
if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w'))
|
||||
electron.remote.getCurrentWindow().close();
|
||||
}
|
||||
// focus search
|
||||
const meta =
|
||||
!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;
|
||||
|
@ -1010,19 +1010,6 @@ module.exports = (store, __exports) => {
|
||||
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),
|
||||
notionUrl =
|
||||
parsed.query.path ||
|
||||
|
@ -246,11 +246,13 @@ module.exports = (store, __exports) => {
|
||||
else showWindows(windows);
|
||||
}
|
||||
tray.on('click', toggleWindows);
|
||||
electron.globalShortcut.register(store().hotkey, () => {
|
||||
const windows = getAllWindows();
|
||||
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
||||
hideWindows(windows);
|
||||
else showWindows(windows);
|
||||
});
|
||||
if (store().hotkey) {
|
||||
electron.globalShortcut.register(store().hotkey, () => {
|
||||
const windows = getAllWindows();
|
||||
if (windows.some((win) => win.isFocused() && win.isVisible()))
|
||||
hideWindows(windows);
|
||||
else showWindows(windows);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user