diff --git a/extension/helpers.js b/extension/helpers.js
index 878f53f..59598ad 100644
--- a/extension/helpers.js
+++ b/extension/helpers.js
@@ -480,7 +480,7 @@ registry.get = async (enabled) => {
const mod = await fs.getJSON(`repo/${dir}/mod.json`);
mod._dir = dir;
mod.tags = mod.tags ?? [];
- mod.css = mod.css ?? [];
+ mod.css = mod.css ?? {};
mod.js = mod.js ?? {};
mod.options = mod.options ?? [];
diff --git a/extension/repo/custom-inserts@2f914210-faae-4803-8e3d-f2bf358a5864/mod.json b/extension/repo/custom-inserts@2f914210-faae-4803-8e3d-f2bf358a5864/mod.json
index b285d64..d17dc2f 100644
--- a/extension/repo/custom-inserts@2f914210-faae-4803-8e3d-f2bf358a5864/mod.json
+++ b/extension/repo/custom-inserts@2f914210-faae-4803-8e3d-f2bf358a5864/mod.json
@@ -4,7 +4,7 @@
"version": "0.11.0",
"description": "the enhancer's [graphical](https://github.com) menu, related buttons and shortcuts.",
"preview": "https://raw.githubusercontent.com/notion-enhancer/notion-enhancer/dev/notion-enhancer%20v0.10.0%20banner.jpg",
- "tags": ["core"],
+ "tags": ["theme", "light"],
"authors": [
{
"name": "dragonwocky",
diff --git a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.js b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.js
index b3187e3..0beccda 100644
--- a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.js
+++ b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/client.js
@@ -7,7 +7,7 @@
'use strict';
const _id = 'a6621988-551d-495a-97d8-3c568bca2e9e';
-import { env, storage, web, fs } from '../../helpers.js';
+import { env, storage, web, fs, registry } from '../../helpers.js';
const sidebarSelector =
'#notion-app > div > div.notion-cursor-listener > div.notion-sidebar-container > div > div > div > div:nth-child(4)';
@@ -20,6 +20,7 @@ web.whenReady([sidebarSelector]).then(async () => {
`
),
+ errors = await registry.errors(),
notifications = {
list: await fs.getJSON('https://notion-enhancer.github.io/notifications.json'),
dismissed: await storage.get(_id, 'notifications', []),
@@ -27,11 +28,13 @@ web.whenReady([sidebarSelector]).then(async () => {
notifications.waiting = notifications.list.filter(
({ id }) => !notifications.dismissed.includes(id)
);
- if (notifications.waiting.length) {
+ if (notifications.waiting.length + errors.length) {
$enhancerSidebarElement.classList.add('enhancer--notifications');
$enhancerSidebarElement.children[0].append(
web.createElement(
- web.html`
${notifications.waiting.length}
`
+ web.html`${
+ notifications.waiting.length + errors.length
+ }
`
)
);
}
diff --git a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.js b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.js
index 8bee594..6594e61 100644
--- a/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.js
+++ b/extension/repo/menu@a6621988-551d-495a-97d8-3c568bca2e9e/menu.js
@@ -54,7 +54,7 @@ components.card = {
src="${web.escapeHtml(preview)}"
/>`)
: '',
- async name({ name, id, version }) {
+ async name({ name, id, version, tags }) {
if (registry.CORE.includes(id))
return web.createElement(web.html`
@@ -76,9 +76,28 @@ components.card = {
`);
- $el.addEventListener('change', async (event) =>
- storage.set('_enabled', id, !(await storage.get('_enabled', id, false)))
- );
+ $el.addEventListener('change', async (event) => {
+ storage.set('_enabled', id, event.target.checked);
+ if (
+ event.target.checked &&
+ tags.includes('theme') &&
+ (await storage.get(_id, 'themes.autoresolve', true))
+ ) {
+ const themes = (await registry.get()).filter(
+ (mod) =>
+ mod.tags.includes('theme') &&
+ mod.id !== id &&
+ ((mod.tags.includes('dark') && tags.includes('dark')) ||
+ (mod.tags.includes('light') && tags.includes('light')))
+ );
+ for (const theme of themes) {
+ if (document.body.dataset.view === 'library') {
+ const $toggle = document.getElementById(`enable--${theme.id}`);
+ if ($toggle.checked) $toggle.click();
+ } else storage.set('_enabled', theme.id, false);
+ }
+ }
+ });
return $el;
},
tags: ({ tags = [] }) =>
@@ -425,7 +444,8 @@ window.addEventListener('popstate', (event) => {
});
const notifications = {
- _generate({ heading, message = '', type = 'information' }, onDismiss = () => {}) {
+ $list: document.querySelector('.notification--list'),
+ push({ heading, message = '', type = 'information' }, onDismiss = () => {}) {
let svg = '',
className = 'notification';
switch (type) {
@@ -462,7 +482,7 @@ const notifications = {
setTimeout(() => {
$notif.style.opacity = 1;
}, 100);
- return $notif;
+ return this.$list.append($notif);
},
async fetch() {
const notifications = {
@@ -473,7 +493,6 @@ const notifications = {
notifications.waiting = notifications.list.filter(
({ id }) => !notifications.dismissed.includes(id)
);
- const $list = document.querySelector('.notification--list');
for (let notification of notifications.waiting) {
if (
notification.heading &&
@@ -482,16 +501,23 @@ const notifications = {
notification.appears_on.versions.includes(env.version)) &&
notification.appears_on.extension
) {
- $list.append(
- this._generate(notification, async () => {
- const dismissed = await storage.get(_id, 'notifications', []);
- storage.set(_id, 'notifications', [...new Set([...dismissed, notification.id])]);
- })
- );
+ this.push(notification, async () => {
+ const dismissed = await storage.get(_id, 'notifications', []);
+ storage.set('_notifications', 'external', [
+ ...new Set([...dismissed, notification.id]),
+ ]);
+ });
}
}
},
};
+for (const error of await registry.errors()) {
+ notifications.push({
+ heading: `error: ${error.source}`,
+ message: error.message,
+ type: 'warning',
+ });
+}
notifications.fetch();
async function theme() {
diff --git a/extension/repo/registry.json b/extension/repo/registry.json
index 3a9ca07..ca97786 100644
--- a/extension/repo/registry.json
+++ b/extension/repo/registry.json
@@ -1 +1,6 @@
-["menu@a6621988-551d-495a-97d8-3c568bca2e9e", "theming@0f0bf8b6-eae6-4273-b307-8fc43f2ee082"]
+[
+ "menu@a6621988-551d-495a-97d8-3c568bca2e9e",
+ "theming@0f0bf8b6-eae6-4273-b307-8fc43f2ee082",
+ "custom-inserts@2f914210-faae-4803-8e3d-f2bf358a5864",
+ "tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2"
+]
diff --git a/extension/repo/tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2/mod.json b/extension/repo/tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2/mod.json
new file mode 100644
index 0000000..3944b87
--- /dev/null
+++ b/extension/repo/tweaks@5174a483-c88d-4bf8-a95f-35cd330b76e2/mod.json
@@ -0,0 +1,54 @@
+{
+ "name": "tweaks",
+ "id": "5174a483-c88d-4bf8-a95f-35cd330b76e2",
+ "version": "0.11.0",
+ "description": "the enhancer's [graphical](https://github.com) menu, related buttons and shortcuts.",
+ "preview": "https://raw.githubusercontent.com/notion-enhancer/notion-enhancer/dev/notion-enhancer%20v0.10.0%20banner.jpg",
+ "tags": ["theme", "light"],
+ "authors": [
+ {
+ "name": "dragonwocky",
+ "email": "thedragonring.bod@gmail.com",
+ "url": "https://dragonwocky.me/",
+ "icon": "https://dragonwocky.me/avatar.jpg"
+ }
+ ],
+ "js": {},
+ "options": [
+ {
+ "type": "toggle",
+ "key": "toggle",
+ "label": "toggle",
+ "value": true,
+ "tooltip": "a toggle"
+ },
+ {
+ "type": "select",
+ "key": "select",
+ "label": "select",
+ "values": ["option a", "option b", "option c"],
+ "tooltip": "a select"
+ },
+ {
+ "type": "text",
+ "key": "text",
+ "label": "text",
+ "value": "default",
+ "tooltip": "a text input"
+ },
+ {
+ "type": "number",
+ "key": "number",
+ "label": "number",
+ "value": 0,
+ "tooltip": "a number input"
+ },
+ {
+ "type": "file",
+ "key": "file",
+ "label": "file picker (.css only)",
+ "extensions": [".css"],
+ "tooltip": "a file picker"
+ }
+ ]
+}