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

Commit

Permalink
Merge pull request #72 from amv146/dev
Browse files Browse the repository at this point in the history
toggle header indentation lines, adjacent tab nav hotkeys
  • Loading branch information
dragonwocky authored Mar 10, 2022
2 parents 9c4b476 + 5287122 commit 3777e6f
Show file tree
Hide file tree
Showing 6 changed files with 81 additions and 5 deletions.
10 changes: 9 additions & 1 deletion indentation-lines/client.css
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,21 @@
.notion-page-content .notion-numbered_list-block > div > div:last-child,
.notion-page-content .notion-to_do-block > div > div:last-child,
.notion-page-content .notion-toggle-block > div > div:last-child,
.notion-page-content .notion-selectable.notion-sub_header-block > div > div > div:last-child,
.notion-page-content .notion-selectable.notion-sub_sub_header-block > div > div > div:last-child,
.notion-page-content .notion-selectable.notion-sub_sub_sub_header-block > div > div > div:last-child,
.notion-page-content .notion-table_of_contents-block > div > div > a > div > div {
position: relative;
}

.notion-page-content .notion-bulleted_list-block > div > div:last-child::before,
.notion-page-content .notion-numbered_list-block > div > div:last-child::before,
.notion-page-content .notion-to_do-block > div > div:last-child::before,
.notion-page-content .notion-toggle-block > div > div:last-child::before {
.notion-page-content .notion-toggle-block > div > div:last-child::before,
.notion-page-content .notion-selectable.notion-sub_header-block > div > div > div:last-child::before,
.notion-page-content .notion-selectable.notion-sub_sub_header-block > div > div > div:last-child::before,
.notion-page-content .notion-selectable.notion-sub_sub_sub_header-block > div > div > div:last-child::before,
.notion-page-content .pseudoSelection > div > div:last-child::before {
content: '';
position: absolute;
height: calc(100% - 2em);
Expand Down Expand Up @@ -93,3 +100,4 @@
> .plus:hover {
background: var(--theme--ui_interactive-hover) !important;
}

16 changes: 15 additions & 1 deletion indentation-lines/client.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,21 @@ export default async function ({ web }, db) {
}
}
}

if (await db.get(['toggle_header'])) {
css += `
.notion-page-content .notion-selectable.notion-sub_sub_header-block > div > div > div:last-child::before {
border-left: 1px ${style} var(--indentation_lines--color, currentColor);
opacity: ${opacity};
}
.notion-page-content .notion-selectable.notion-sub_header-block > div > div > div:last-child::before {
border-left: 1px ${style} var(--indentation_lines--color, currentColor);
opacity: ${opacity};
}
.notion-page-content .notion-selectable.notion-sub_sub_sub_header-block > div > div > div:last-child::before {
border-left: 1px ${style} var(--indentation_lines--color, currentColor);
opacity: ${opacity};
}`;
}
if (db.get(['table_of_contents'])) {
css += `
.notion-page-content .notion-table_of_contents-block > div > div > a > div
Expand Down
6 changes: 6 additions & 0 deletions indentation-lines/mod.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
"label": "toggle lists",
"value": true
},
{
"type": "toggle",
"key": "toggle_header",
"label": "toggle headers",
"value": true
},
{
"type": "toggle",
"key": "table_of_contents",
Expand Down
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

0 comments on commit 3777e6f

Please sign in to comment.