mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-10 15:39:01 +00:00
Added Ctrl-Tab and Ctrl-Shift-Tab functionality
This commit is contained in:
parent
6c1e6ffbce
commit
300f876a28
@ -10,14 +10,14 @@ export default async function ({ web, electron }, db) {
|
|||||||
const newTabHotkey = await db.get(['new_tab']),
|
const newTabHotkey = await db.get(['new_tab']),
|
||||||
closeTabHotkey = await db.get(['close_tab']),
|
closeTabHotkey = await db.get(['close_tab']),
|
||||||
restoreTabHotkey = await db.get(['restore_tab']),
|
restoreTabHotkey = await db.get(['restore_tab']),
|
||||||
selectTabModifier = await db.get(['select_modifier']);
|
selectTabModifier = await db.get(['select_modifier']),
|
||||||
|
prevTabHotkey = await db.get(['prev_tab']),
|
||||||
|
nextTabHotkey = await db.get(['next_tab']);
|
||||||
web.addHotkeyListener(newTabHotkey, () => {
|
web.addHotkeyListener(newTabHotkey, () => {
|
||||||
electron.sendMessageToHost('new-tab');
|
electron.sendMessageToHost('new-tab');
|
||||||
console.log('new-tab');
|
|
||||||
});
|
});
|
||||||
web.addHotkeyListener(restoreTabHotkey, () => {
|
web.addHotkeyListener(restoreTabHotkey, () => {
|
||||||
electron.sendMessageToHost('restore-tab');
|
electron.sendMessageToHost('restore-tab');
|
||||||
console.log('restore-tab');
|
|
||||||
});
|
});
|
||||||
web.addHotkeyListener(closeTabHotkey, () => electron.sendMessageToHost('close-tab'));
|
web.addHotkeyListener(closeTabHotkey, () => electron.sendMessageToHost('close-tab'));
|
||||||
for (let i = 1; i < 10; i++) {
|
for (let i = 1; i < 10; i++) {
|
||||||
@ -25,6 +25,12 @@ export default async function ({ web, electron }, db) {
|
|||||||
electron.sendMessageToHost('select-tab', i);
|
electron.sendMessageToHost('select-tab', i);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
web.addHotkeyListener(prevTabHotkey, () => {
|
||||||
|
electron.sendMessageToHost('select-prev-tab')
|
||||||
|
});
|
||||||
|
web.addHotkeyListener(nextTabHotkey, () => {
|
||||||
|
electron.sendMessageToHost('select-next-tab')
|
||||||
|
});
|
||||||
|
|
||||||
const breadcrumbSelector =
|
const breadcrumbSelector =
|
||||||
'.notion-topbar > div > [class="notranslate"] > .notion-focusable:last-child',
|
'.notion-topbar > div > [class="notranslate"] > .notion-focusable:last-child',
|
||||||
|
@ -62,6 +62,18 @@
|
|||||||
"Super+Shift"
|
"Super+Shift"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"type": "hotkey",
|
||||||
|
"key": "prev_tab",
|
||||||
|
"label": "previous tab hotkey",
|
||||||
|
"value": "Control+Shift+Tab"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "hotkey",
|
||||||
|
"key": "next_tab",
|
||||||
|
"label": "next tab hotkey",
|
||||||
|
"value": "Control+Tab"
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"type": "hotkey",
|
"type": "hotkey",
|
||||||
"key": "new_tab",
|
"key": "new_tab",
|
||||||
|
@ -228,6 +228,36 @@ module.exports = async function (api, db, tabCache = new Map()) {
|
|||||||
const $tab = i === 9 ? this.$tabList.lastElementChild : this.$tabList.children[i - 1];
|
const $tab = i === 9 ? this.$tabList.lastElementChild : this.$tabList.children[i - 1];
|
||||||
if ($tab) $tab.click();
|
if ($tab) $tab.click();
|
||||||
});
|
});
|
||||||
|
fromNotion('notion-enhancer:select-prev-tab', () => {
|
||||||
|
if (this.$tabList.count == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const $sibling = this.$tab.previousElementSibling;
|
||||||
|
if ($sibling) {
|
||||||
|
$sibling.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let $tab = this.$tabList.lastElementChild;
|
||||||
|
if ($tab) {
|
||||||
|
$tab.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fromNotion('notion-enhancer:select-next-tab', () => {
|
||||||
|
if (this.$tabList.count == 1) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const $sibling = this.$tab.nextElementSibling;
|
||||||
|
if ($sibling) {
|
||||||
|
$sibling.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
let $tab = this.$tabList.children[0]
|
||||||
|
if ($tab) {
|
||||||
|
$tab.click();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
#firstQuery = true;
|
#firstQuery = true;
|
||||||
|
Loading…
Reference in New Issue
Block a user