mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-05 13:19:03 +00:00
side-panel: bind toggling to Ctrl+Shift+Backslash
This commit is contained in:
parent
8267d8e143
commit
e8f8576f63
@ -117,16 +117,31 @@ module.exports = {
|
||||
// Add switcher if there is more than one panel mods
|
||||
if (panelMods.length > 1) {
|
||||
header.addEventListener('click', renderSwitcher);
|
||||
|
||||
const switcherIcon = createElement(
|
||||
`<div class="enhancer-panel--switcher-icon">${icons.switcher}</div>`
|
||||
)
|
||||
header.appendChild(switcherIcon);
|
||||
} else header.addEventListener('click', togglePanel);
|
||||
} else {
|
||||
header.addEventListener('click', togglePanel);
|
||||
}
|
||||
|
||||
header.appendChild(toggle);
|
||||
toggle.addEventListener('click', togglePanel);
|
||||
|
||||
// Keybind
|
||||
document.addEventListener('keyup', e => {
|
||||
const hotkey = {
|
||||
code: 'Backslash',
|
||||
ctrlKey: true,
|
||||
shiftKey: true,
|
||||
metaKey: false,
|
||||
altKey: false,
|
||||
};
|
||||
for (let prop in hotkey)
|
||||
if (hotkey[prop] !== e[prop]) return;
|
||||
togglePanel();
|
||||
});
|
||||
|
||||
// Restore lock state
|
||||
if (store().locked === 'true') lockPanel();
|
||||
else unlockPanel(false);
|
||||
@ -154,7 +169,7 @@ module.exports = {
|
||||
store().last_open = mod.id;
|
||||
panel.querySelector('.enhancer-panel--title').innerHTML = mod.panel.name || mod.name;
|
||||
|
||||
// reload button
|
||||
// Reload button
|
||||
let reloadButton = document.querySelector('.enhancer-panel--reload-button');
|
||||
if (reloadButton) reloadButton.remove();
|
||||
if (mod.panel.reload) {
|
||||
@ -222,7 +237,7 @@ module.exports = {
|
||||
}
|
||||
|
||||
function togglePanel(e) {
|
||||
e.stopPropagation();
|
||||
if (e) e.stopPropagation();
|
||||
if (isLocked()) unlockPanel(true);
|
||||
else lockPanel();
|
||||
store().locked = panel.dataset.locked;
|
||||
|
Loading…
Reference in New Issue
Block a user