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,15 +117,30 @@ module.exports = {
|
|||||||
// Add switcher if there is more than one panel mods
|
// Add switcher if there is more than one panel mods
|
||||||
if (panelMods.length > 1) {
|
if (panelMods.length > 1) {
|
||||||
header.addEventListener('click', renderSwitcher);
|
header.addEventListener('click', renderSwitcher);
|
||||||
|
|
||||||
const switcherIcon = createElement(
|
const switcherIcon = createElement(
|
||||||
`<div class="enhancer-panel--switcher-icon">${icons.switcher}</div>`
|
`<div class="enhancer-panel--switcher-icon">${icons.switcher}</div>`
|
||||||
)
|
)
|
||||||
header.appendChild(switcherIcon);
|
header.appendChild(switcherIcon);
|
||||||
} else header.addEventListener('click', togglePanel);
|
} else {
|
||||||
|
header.addEventListener('click', togglePanel);
|
||||||
|
}
|
||||||
|
|
||||||
header.appendChild(toggle);
|
header.appendChild(toggle);
|
||||||
toggle.addEventListener('click', togglePanel);
|
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
|
// Restore lock state
|
||||||
if (store().locked === 'true') lockPanel();
|
if (store().locked === 'true') lockPanel();
|
||||||
@ -154,7 +169,7 @@ module.exports = {
|
|||||||
store().last_open = mod.id;
|
store().last_open = mod.id;
|
||||||
panel.querySelector('.enhancer-panel--title').innerHTML = mod.panel.name || mod.name;
|
panel.querySelector('.enhancer-panel--title').innerHTML = mod.panel.name || mod.name;
|
||||||
|
|
||||||
// reload button
|
// Reload button
|
||||||
let reloadButton = document.querySelector('.enhancer-panel--reload-button');
|
let reloadButton = document.querySelector('.enhancer-panel--reload-button');
|
||||||
if (reloadButton) reloadButton.remove();
|
if (reloadButton) reloadButton.remove();
|
||||||
if (mod.panel.reload) {
|
if (mod.panel.reload) {
|
||||||
@ -222,7 +237,7 @@ module.exports = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function togglePanel(e) {
|
function togglePanel(e) {
|
||||||
e.stopPropagation();
|
if (e) e.stopPropagation();
|
||||||
if (isLocked()) unlockPanel(true);
|
if (isLocked()) unlockPanel(true);
|
||||||
else lockPanel();
|
else lockPanel();
|
||||||
store().locked = panel.dataset.locked;
|
store().locked = panel.dataset.locked;
|
||||||
|
Loading…
Reference in New Issue
Block a user