remove extension menu hotkey conflict + make configurable

This commit is contained in:
dragonwocky 2020-09-02 20:40:35 +10:00
parent 0355c7d344
commit 513b5f4cab
5 changed files with 21 additions and 8 deletions

View File

@ -19,8 +19,6 @@ module.exports = (store, __exports) => {
// additional hotkeys
document.defaultView.addEventListener('keyup', (event) => {
if (event.code === 'F5') location.reload();
if (event.key === 'e' && (event.ctrlKey || event.metaKey))
electron.ipcRenderer.send('enhancer:open-extension-menu');
});
const attempt_interval = setInterval(enhance, 500);

View File

@ -19,7 +19,6 @@ window['__start'] = async () => {
document.defaultView.addEventListener('keyup', (event) => {
if (event.code === 'F5') location.reload();
if ((event.ctrlKey || event.metaKey) && event.key === 'e') browser.close();
if (!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey) {
if (
document.activeElement.parentElement.id === 'tags' &&
@ -458,6 +457,7 @@ window['__start'] = async () => {
$opt
.querySelector(`#${opt.type}_${mod.id}--${opt.key}`)
.addEventListener('change', (event) => {
modified();
if (opt.type === 'toggle') {
store(mod.id)[opt.key] = event.target.checked;
} else if (opt.type === 'file') {
@ -469,9 +469,8 @@ window['__start'] = async () => {
} else
store(mod.id)[opt.key] =
typeof opt.value === 'number'
? Number(event.target.value)
? +event.target.value
: event.target.value;
modified();
});
}
$options.appendChild($opt);

View File

@ -56,6 +56,12 @@ module.exports = {
type: 'input',
value: 'CommandOrControl+Shift+A',
},
{
key: 'menu_toggle',
label: 'open enhancements menu hotkey:',
type: 'input',
value: 'Alt+E',
},
],
hacks: {
'main/main.js': require('./tray.js'),

View File

@ -40,7 +40,6 @@ module.exports = (store, __exports) => {
webContents.send('enhancer:get-theme-vars', arg)
);
});
electron.ipcMain.on('enhancer:open-extension-menu', openExtensionMenu);
function calculateWindowPos(width, height) {
const screen = electron.screen.getDisplayNearestPoint({
@ -157,7 +156,7 @@ module.exports = (store, __exports) => {
{
type: 'normal',
label: 'Enhancements',
accelerator: 'CommandOrControl+E',
accelerator: store().menu_toggle,
click: openExtensionMenu,
},
{
@ -193,6 +192,17 @@ module.exports = (store, __exports) => {
tray.setContextMenu(contextMenu);
tray.setToolTip('Notion');
electron.globalShortcut.register(store().menu_toggle, () => {
if (
electron.BrowserWindow.getAllWindows()
.filter((win) => win.getTitle() !== 'notion-enhancer menu')
.some((win) => win.isFocused())
) {
openExtensionMenu();
} else if (enhancer_menu && enhancer_menu.isFocused())
enhancer_menu.close();
});
function showWindows() {
const windows = electron.BrowserWindow.getAllWindows();
if (is_mac) electron.app.show();

View File

@ -46,7 +46,7 @@ module.exports = {
: 0;
for (let day of days)
day.parentElement.parentElement.style.height = 0;
today.parentElement.parentElement.style.height = height;
if (today) today.parentElement.parentElement.style.height = height;
}
}
});