Skip to content
This repository has been archived by the owner on Feb 7, 2024. It is now read-only.

toggle header indentation lines, adjacent tab nav hotkeys #72

Merged
merged 2 commits into from
Mar 10, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added Ctrl-Tab and Ctrl-Shift-Tab functionality
  • Loading branch information
amv146 committed Feb 9, 2022
commit 5287122c81f6e420adf68e1bfc42d8ba23d68b7e
12 changes: 9 additions & 3 deletions tabs/client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,27 @@ export default async function ({ web, electron }, db) {
const newTabHotkey = await db.get(['new_tab']),
closeTabHotkey = await db.get(['close_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, () => {
electron.sendMessageToHost('new-tab');
console.log('new-tab');
});
web.addHotkeyListener(restoreTabHotkey, () => {
electron.sendMessageToHost('restore-tab');
console.log('restore-tab');
});
web.addHotkeyListener(closeTabHotkey, () => electron.sendMessageToHost('close-tab'));
for (let i = 1; i < 10; i++) {
web.addHotkeyListener([selectTabModifier, i.toString()], () => {
electron.sendMessageToHost('select-tab', i);
});
}
web.addHotkeyListener(prevTabHotkey, () => {
electron.sendMessageToHost('select-prev-tab')
});
web.addHotkeyListener(nextTabHotkey, () => {
electron.sendMessageToHost('select-next-tab')
});

const breadcrumbSelector =
'.notion-topbar > div > [class="notranslate"] > .notion-focusable:last-child',
Expand Down
12 changes: 12 additions & 0 deletions tabs/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,18 @@
"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",
"key": "new_tab",
Expand Down
30 changes: 30 additions & 0 deletions tabs/tab.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -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];
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;
Expand Down