mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
use keyup listeners instead of a globalShortcut for the enhancements menu toggle
This commit is contained in:
parent
61206db05a
commit
d75368b020
@ -19,6 +19,7 @@ a flexibility update.
|
||||
- new: relaunch button in tray menu.
|
||||
- improved: a core mod option to make transitions snappy/0s.
|
||||
- improved: menu will now respect integrated titlebar setting.
|
||||
- improved: use keyup listeners instead of a globalShortcut for the enhancements menu toggle.
|
||||
- bugfix: removed messenger emoji set as the provider no longer supports it.
|
||||
- bugfix: remove shadow around light mode board headers
|
||||
\+ minor text colour fixes for night shift theming.
|
||||
|
@ -13,11 +13,18 @@ module.exports = (store, __exports) => {
|
||||
notionIpc = require(`${helpers.__notion.replace(
|
||||
/\\/g,
|
||||
'/'
|
||||
)}/app/helpers/notionIpc.js`);
|
||||
)}/app/helpers/notionIpc.js`),
|
||||
{ toKeyEvent } = require('keyboardevent-from-electron-accelerator');
|
||||
|
||||
// additional hotkeys
|
||||
document.defaultView.addEventListener('keyup', (event) => {
|
||||
if (event.code === '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]) triggered = false;
|
||||
if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
|
||||
});
|
||||
|
||||
const attempt_interval = setInterval(enhance, 500);
|
||||
|
@ -10,7 +10,8 @@ const store = require('../../pkg/store.js'),
|
||||
helpers = require('../../pkg/helpers.js'),
|
||||
fs = require('fs-extra'),
|
||||
path = require('path'),
|
||||
electron = require('electron');
|
||||
electron = require('electron'),
|
||||
{ toKeyEvent } = require('keyboardevent-from-electron-accelerator');
|
||||
|
||||
window['__start'] = async () => {
|
||||
const buttons = require('./buttons.js')(() => ({
|
||||
@ -141,9 +142,22 @@ window['__start'] = async () => {
|
||||
document.addEventListener('keyup', (event) => {
|
||||
if (
|
||||
$popup.classList.contains('visible') &&
|
||||
[13, 27].includes(event.keyCode)
|
||||
['Enter', 'Escape'].includes(event.key)
|
||||
)
|
||||
$popup.classList.remove('visible');
|
||||
// close window on hotkey toggle
|
||||
console.log();
|
||||
const hotkey = toKeyEvent(
|
||||
store('0f0bf8b6-eae6-4273-b307-8fc43f2ee082', {
|
||||
menu_toggle: modules.loaded
|
||||
.find((m) => m.id === '0f0bf8b6-eae6-4273-b307-8fc43f2ee082')
|
||||
.options.find((o) => o.key === 'menu_toggle').value,
|
||||
}).menu_toggle
|
||||
);
|
||||
let triggered = true;
|
||||
for (let prop in hotkey)
|
||||
if (hotkey[prop] !== event[prop]) triggered = false;
|
||||
if (triggered) electron.remote.getCurrentWindow().close();
|
||||
});
|
||||
let colorpicker_target = null;
|
||||
const $colorpicker = colorjoe
|
||||
|
@ -32,6 +32,9 @@ module.exports = (store, __exports) => {
|
||||
|
||||
// menu
|
||||
|
||||
electron.ipcMain.on('enhancer:open-menu', (event, arg) => {
|
||||
openExtensionMenu();
|
||||
});
|
||||
electron.ipcMain.on('enhancer:set-menu-theme', (event, arg) => {
|
||||
if (!enhancer_menu) return;
|
||||
enhancer_menu.webContents.send('enhancer:set-menu-theme', arg);
|
||||
@ -115,17 +118,6 @@ module.exports = (store, __exports) => {
|
||||
});
|
||||
}
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
// tray
|
||||
|
||||
const contextMenu = electron.Menu.buildFromTemplate([
|
||||
|
@ -117,12 +117,12 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
||||
`file access forbidden - ${
|
||||
process.platform === 'win32'
|
||||
? 'make sure your user has elevated permissions.'
|
||||
: `try running "sudo chmod a+wr -R ${err.path.replace(
|
||||
: `try running "sudo chmod -R a+wr ${err.path.replace(
|
||||
'Notion.app',
|
||||
'Notion'
|
||||
)}" ${
|
||||
err.dest
|
||||
? `and "sudo chmod a+wr -R ${err.dest.replace(
|
||||
? `and "sudo chmod -R a+wr ${err.dest.replace(
|
||||
'Notion.app',
|
||||
'Notion'
|
||||
)}"`
|
||||
|
@ -119,12 +119,12 @@ module.exports = async function ({
|
||||
`file access forbidden - ${
|
||||
process.platform === 'win32'
|
||||
? 'make sure your user has elevated permissions.'
|
||||
: `try running "sudo chmod a+wr -R ${err.path.replace(
|
||||
: `try running "sudo chmod -R a+wr ${err.path.replace(
|
||||
'Notion.app',
|
||||
'Notion'
|
||||
)}" ${
|
||||
err.dest
|
||||
? `and "sudo chmod a+wr -R ${err.dest.replace(
|
||||
? `and "sudo chmod -R a+wr ${err.dest.replace(
|
||||
'Notion.app',
|
||||
'Notion'
|
||||
)}"`
|
||||
|
Loading…
Reference in New Issue
Block a user