diff --git a/repo/menu/components.mjs b/repo/menu/components.mjs
index 9b2dec0..d013ec2 100644
--- a/repo/menu/components.mjs
+++ b/repo/menu/components.mjs
@@ -8,7 +8,6 @@
import { fmt, web, registry, components } from '../../api/_.mjs';
import { notifications } from './notifications.mjs';
-const profileDB = await registry.profileDB();
export const modComponents = {
preview: (url) => web.html`
{
- const checked = await profileDB.get([mod.id, opt.key], opt.value),
+ const profileDB = await registry.profileDB(),
+ checked = await profileDB.get([mod.id, opt.key], opt.value),
$toggle = modComponents.toggle(opt.label, checked),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = $toggle.children[0],
@@ -71,8 +71,10 @@ export const options = {
});
return $toggle;
},
+
select: async (mod, opt) => {
- const value = await profileDB.get([mod.id, opt.key], opt.values[0]),
+ const profileDB = await registry.profileDB(),
+ value = await profileDB.get([mod.id, opt.key], opt.values[0]),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
@@ -96,8 +98,10 @@ export const options = {
});
return web.render($label, $select, $icon);
},
+
text: async (mod, opt) => {
- const value = await profileDB.get([mod.id, opt.key], opt.value),
+ const profileDB = await registry.profileDB(),
+ value = await profileDB.get([mod.id, opt.key], opt.value),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
@@ -112,8 +116,10 @@ export const options = {
});
return web.render($label, $input, $icon);
},
+
number: async (mod, opt) => {
- const value = await profileDB.get([mod.id, opt.key], opt.value),
+ const profileDB = await registry.profileDB(),
+ value = await profileDB.get([mod.id, opt.key], opt.value),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
@@ -128,8 +134,10 @@ export const options = {
});
return web.render($label, $input, $icon);
},
+
color: async (mod, opt) => {
- const value = await profileDB.get([mod.id, opt.key], opt.value),
+ const profileDB = await registry.profileDB(),
+ value = await profileDB.get([mod.id, opt.key], opt.value),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
@@ -166,8 +174,10 @@ export const options = {
paint();
return web.render($label, $input, $icon);
},
+
file: async (mod, opt) => {
- const { filename } = (await profileDB.get([mod.id, opt.key], {})) || {},
+ const profileDB = await registry.profileDB(),
+ { filename } = (await profileDB.get([mod.id, opt.key], {})) || {},
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
@@ -204,8 +214,10 @@ export const options = {
$latest
);
},
+
hotkey: async (mod, opt) => {
- const value = await profileDB.get([mod.id, opt.key], opt.value),
+ const profileDB = await registry.profileDB(),
+ value = await profileDB.get([mod.id, opt.key], opt.value),
$tooltip = web.html`${await components.feather('info', { class: 'input-tooltip' })}`,
$label = web.render(
web.html``,
diff --git a/repo/menu/menu.mjs b/repo/menu/menu.mjs
index 823c792..9f18c51 100644
--- a/repo/menu/menu.mjs
+++ b/repo/menu/menu.mjs
@@ -8,184 +8,185 @@
import * as api from '../../api/_.mjs';
import { notifications, $changelogModal } from './notifications.mjs';
-const { env, fs, storage, registry, web, components } = api;
-
-for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
- for (const sheet of mod.css?.menu || []) {
- web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
- }
- for (let script of mod.js?.menu || []) {
- script = await import(fs.localPath(`repo/${mod._dir}/${script}`));
- script.default(api, await registry.db(mod.id));
- }
-}
-const errors = await registry.errors();
-if (errors.length) {
- console.log('[notion-enhancer] registry errors:');
- console.table(errors);
- notifications.add({
- icon: 'alert-circle',
- message: 'Failed to load mods (check console).',
- color: 'red',
- });
-}
-
import { modComponents, options } from './components.mjs';
import * as router from './router.mjs';
import './styles.mjs';
-const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
- profileName = await registry.profileName(),
- profileDB = await registry.profileDB();
+(async () => {
+ const { env, fs, storage, registry, web, components } = api;
-web.addHotkeyListener(await db.get(['hotkey']), env.focusNotion);
+ for (const mod of await registry.list((mod) => registry.enabled(mod.id))) {
+ for (const sheet of mod.css?.menu || []) {
+ web.loadStylesheet(`repo/${mod._dir}/${sheet}`);
+ }
+ for (let script of mod.js?.menu || []) {
+ script = await import(fs.localPath(`repo/${mod._dir}/${script}`));
+ script.default(api, await registry.db(mod.id));
+ }
+ }
+ const errors = await registry.errors();
+ if (errors.length) {
+ console.log('[notion-enhancer] registry errors:');
+ console.table(errors);
+ notifications.add({
+ icon: 'alert-circle',
+ message: 'Failed to load mods (check console).',
+ color: 'red',
+ });
+ }
-const loadTheme = async () => {
- document.documentElement.className =
- (await storage.get(['theme'], 'light')) === 'dark' ? 'dark' : '';
-};
-document.addEventListener('visibilitychange', loadTheme);
-loadTheme();
+ const db = await registry.db('a6621988-551d-495a-97d8-3c568bca2e9e'),
+ profileName = await registry.profileName(),
+ profileDB = await registry.profileDB();
-window.addEventListener('beforeunload', (event) => {
- // trigger input save
- document.activeElement.blur();
-});
+ web.addHotkeyListener(await db.get(['hotkey']), env.focusNotion);
-const $main = web.html``,
- $sidebar = web.html``,
- $options = web.html`
+ const loadTheme = async () => {
+ document.documentElement.className =
+ (await storage.get(['theme'], 'light')) === 'dark' ? 'dark' : '';
+ };
+ document.addEventListener('visibilitychange', loadTheme);
+ loadTheme();
+
+ window.addEventListener('beforeunload', (event) => {
+ // trigger input save
+ document.activeElement.blur();
+ });
+
+ const $main = web.html`
`,
+ $sidebar = web.html``,
+ $options = web.html`
Select a mod to view and configure its options.
`,
- $profile = web.html`
`
+);
+
+(async () => {
+ const $changelogModalButton = web.html`
+ Accept & Continue
+ `;
+ $changelogModalButton.addEventListener('click', async () => {
+ $changelogModal.classList.remove('modal-visible');
+ await storage.set(['last_read_changelog'], env.version);
+ });
+
web.render(
- web.html``,
- web.html`
+ $changelogModal,
+ web.render(
+ web.html`
`,
+ web.html`
${(await fs.getText('media/colour.svg')).replace(
/width="\d+" height="\d+"/,
@@ -149,14 +162,13 @@ export const $changelogModal = web.render(
`,
- web.render(web.html``, $changelogModalButton)
- )
-);
-web.render(document.body, $changelogModal);
-if (lastReadChangelog !== env.version) {
- $changelogModal.classList.add('modal-visible');
-}
-$changelogModalButton.addEventListener('click', async () => {
- $changelogModal.classList.remove('modal-visible');
- await storage.set(['last_read_changelog'], env.version);
-});
+ web.render(web.html``, $changelogModalButton)
+ )
+ );
+
+ const lastReadChangelog = await storage.get(['last_read_changelog']);
+ web.render(document.body, $changelogModal);
+ if (lastReadChangelog !== env.version) {
+ $changelogModal.classList.add('modal-visible');
+ }
+})();
diff --git a/repo/theming/theme.css b/repo/theming/theme.css
index 502dedf..c11799a 100644
--- a/repo/theming/theme.css
+++ b/repo/theming/theme.css
@@ -165,7 +165,7 @@ body,
.notion-body.dark
.notion-default-overlay-container
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];'],
-.notion-focusable[style*='background: rgb(80, 85, 88);'],
+.notion-focusable[style*='background: rgb(80, 85, 88);']:not(.notion-help-button):not(.onboarding-checklist-button),
.notion-body:not(.dark)
.notion-default-overlay-container
[style*='grid-template-columns: [boolean-start] 60px [boolean-end property-start] 120px [property-end opererator-start] 110px [operator-end value-start] auto [value-end menu-start] 32px [menu-end];']