diff --git a/CHANGELOG.md b/CHANGELOG.md index ff41253..aaff098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,8 @@ a flexibility update. - improved: overwrite `app.asar.bak` if already exists (e.g. for app updates). - improved: additional menu option descriptions on hover. - improved: listen to prefers-color-scheme to better change theme in night shift. +- improved: platform-specific option overrides for features not required on macOS. +- improved: made extra padding at the bottom with the "focus mode" extension toggleable. - bugfix: removed messenger emoji set as the provider no longer supports it. - bugfix: remove shadow around light mode board headers. - bugfix: properly detect/respond to `EACCES`/`EBUSY` errors. @@ -47,6 +49,8 @@ a flexibility update. - bugfix: keep "empty" top bar visible in the menu. - bugfix: set NSRequiresAquaSystemAppearance to false in /Applications/Notion.app/Contents/Info.plist so system dark/light mode can be properly detected. +- bugfix: make ctrl+f popover shadow less extreme. +- bugfix: "weekly" calendar view name made case insensitive. - tweak: sticky table/list rows. - theme: "material ocean" = an oceanic colour palette. - theme: "dracula" = a theme based on the popular dracula color palette @@ -66,14 +70,6 @@ a flexibility update. a fork of notion-deb-builder that does generate an app.asar has been created and is once again supported. -// todo - -MACOS SPECIFIC FIXES - -- close to tray: perma-true -- frameless mode: perma-false -- open ext. menu hotkey not working? - ### v0.9.1 (2020-09-26) - bugfix: font chooser will continue iterating through fonts after encountering a blank option. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4d3399c..035439f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -25,20 +25,24 @@ join the [discord server](https://discord.gg/sFWPXtA). ## testing -download: +first, remove any other installations of the enhancer: `npm remove -g notion-enhancer` + +to download and install the latest code, run: ```sh git clone https://github.com/dragonwocky/notion-enhancer cd notion-enhancer git checkout dev npm link +notion-enhancer apply -y ``` -the downloaded folder is now directly linked to the `notion-enhancer` command. +to remove the dev build, go into the downloaded folder and run: -no written tests are included with the enhancer: -i don't have the experience/skill with them yet to use them effectively. -if you can add some for your code, though, go ahead! +```sh +notion-enhancer remove -n +npm unlink +``` ## conventions diff --git a/mods/core/client.js b/mods/core/client.js index 46142a8..0ddafe2 100644 --- a/mods/core/client.js +++ b/mods/core/client.js @@ -25,7 +25,11 @@ module.exports = (store, __exports) => { const hotkey = toKeyEvent(store().menu_toggle); let triggered = true; for (let prop in hotkey) - if (hotkey[prop] !== event[prop]) triggered = false; + if ( + hotkey[prop] !== event[prop] && + !(prop === 'key' && event[prop] === 'Dead') + ) + triggered = false; if (triggered) electron.ipcRenderer.send('enhancer:open-menu'); if (tabsEnabled) { // switch between tabs via key modifier @@ -117,22 +121,20 @@ module.exports = (store, __exports) => { ? 'dark' : 'light', 'colors': { - 'white': getStyle(`--theme--option_active-color`), - 'blue': getStyle(`--theme--option_active-background`), + 'white': getStyle('--theme--option_active-color'), + 'blue': getStyle('--theme--option_active-background'), }, 'borderRadius': 3, - 'textColor': getStyle(`--theme--text`), - 'popoverBackgroundColor': getStyle(`--theme--card`), - 'popoverBoxShadow': `0 0 0 1px ${getStyle( - `--theme--overlay` - )}, 0 3px 6px ${getStyle(`--theme--overlay`)}`, + 'textColor': getStyle('--theme--text'), + 'popoverBackgroundColor': getStyle('--theme--card'), + 'popoverBoxShadow': getStyle('--theme--box-shadow_strong'), 'inputBoxShadow': `box-shadow: ${getStyle( `--theme--primary` )} 0px 0px 0px 1px inset, ${getStyle( `--theme--primary_hover` )} 0px 0px 0px 2px !important`, - 'inputBackgroundColor': getStyle(`--theme--main`), - 'dividerColor': getStyle(`--theme--table-border`), + 'inputBackgroundColor': getStyle('--theme--main'), + 'dividerColor': getStyle('--theme--table-border'), 'shadowOpacity': 0.2, }); } @@ -216,6 +218,10 @@ module.exports = (store, __exports) => { if (tabsEnabled) { let tab_title = ''; + if (process.platform === 'darwin') + document + .querySelector('.notion-sidebar [style*="37px"]:empty') + .remove(); const TITLE_OBSERVER = new MutationObserver(() => __electronApi.setWindowTitle('notion.so') ); @@ -234,9 +240,13 @@ module.exports = (store, __exports) => { ), text = $container.querySelector('[placeholder="Untitled"]'); title = - (icon ? `` : '') + + (icon + ? icon.getAttribute('src') + ? `` + : `${icon.getAttribute('aria-label')} ` + : '') + (text - ? text.innerText + ? text.innerText || 'Untitled' : [ setTimeout(() => __electronApi.setWindowTitle(title), 250), title, diff --git a/mods/core/enhancerMenu.js b/mods/core/enhancerMenu.js index 7b3b706..de09afa 100644 --- a/mods/core/enhancerMenu.js +++ b/mods/core/enhancerMenu.js @@ -131,7 +131,11 @@ window['__start'] = async () => { const hotkey = toKeyEvent(coreStore().menu_toggle); let triggered = true; for (let prop in hotkey) - if (hotkey[prop] !== event[prop]) triggered = false; + if ( + hotkey[prop] !== event[prop] && + !(prop === 'key' && event[prop] === 'Dead') + ) + triggered = false; if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w')) electron.remote.getCurrentWindow().close(); // focus search @@ -587,6 +591,13 @@ window['__start'] = async () => { const $options = mod.elem.querySelector('.options'); if ($options) for (const opt of mod.options) { + if ( + Object.keys(opt.platformOverwrite || {}).some( + (platform) => process.platform === platform + ) + ) { + continue; + } const $opt = createOption(opt, mod.id); if (opt.type === 'color') { const $preview = $opt.querySelector('input'); diff --git a/mods/core/mod.js b/mods/core/mod.js index 4772901..61cd942 100644 --- a/mods/core/mod.js +++ b/mods/core/mod.js @@ -46,6 +46,9 @@ module.exports = { it can be re-shown by clicking the tray icon or using the hotkey.`, type: 'toggle', value: true, + platformOverwrite: { + darwin: true, + }, }, { key: 'frameless', @@ -53,6 +56,9 @@ module.exports = { description: `replace the native titlebar with buttons inset into the app.`, type: 'toggle', value: true, + platformOverwrite: { + darwin: false, + }, }, { key: 'tiling_mode', diff --git a/mods/core/render.js b/mods/core/render.js index 92cb337..12252a1 100644 --- a/mods/core/render.js +++ b/mods/core/render.js @@ -994,7 +994,11 @@ module.exports = (store, __exports) => { const hotkey = toKeyEvent(store().menu_toggle); let triggered = true; for (let prop in hotkey) - if (hotkey[prop] !== event[prop]) triggered = false; + if ( + hotkey[prop] !== event[prop] && + !(prop === 'key' && event[prop] === 'Dead') + ) + triggered = false; if (triggered) electron.ipcRenderer.send('enhancer:open-menu'); }); diff --git a/mods/focus-mode/mod.js b/mods/focus-mode/mod.js index 10994ac..5546cbd 100644 --- a/mods/focus-mode/mod.js +++ b/mods/focus-mode/mod.js @@ -13,6 +13,24 @@ module.exports = { name: 'focus mode', desc: 'hide the titlebar/menubar if the sidebar is closed (will be shown on hover).', - version: '0.1.1', + version: '0.2.0', author: 'arecsu', + options: [ + { + key: 'padded', + label: 'add padding to bottom of the page', + description: `will only take effect when the sidebar is hidden. aims to make the canvas\ + as symmetrical/consistent as possible: if there is empty space on 3 sides, the 4th should follow.z`, + type: 'toggle', + value: true, + }, + ], + hacks: { + 'renderer/preload.js': (store, __exports) => { + document.addEventListener('readystatechange', (event) => { + if (document.readyState !== 'complete') return false; + if (store().padded) document.body.dataset.focusmode = 'padded'; + }); + }, + }, }; diff --git a/mods/focus-mode/styles.css b/mods/focus-mode/styles.css index c71829f..032761f 100644 --- a/mods/focus-mode/styles.css +++ b/mods/focus-mode/styles.css @@ -5,16 +5,6 @@ * under the MIT license */ -/* add space at the bottom of the main frame when sidebar is hidden - * -- matches space at top for titlebar */ -.notion-dark-theme .notion-frame { - transition: height 100ms ease 0s; -} -.notion-sidebar-container[style*='width: 0px;'] + .notion-frame { - height: calc( - 100% - (var(--configured--dragarea_height, 10px) + 45px) - ) !important; -} .notion-sidebar-container[style*='width: 0px;'] + .notion-frame .notion-topbar { opacity: 0 !important; transition: opacity 200ms ease-in-out !important; @@ -24,3 +14,15 @@ .notion-topbar:hover { opacity: 1 !important; } +/* add space at the bottom of the main frame when sidebar is hidden +* -- matches space at top for titlebar */ +[data-focusmode='padded'] .notion-dark-theme .notion-frame { + transition: height 100ms ease 0s; +} +[data-focusmode='padded'] + .notion-sidebar-container[style*='width: 0px;'] + + .notion-frame { + height: calc( + 100% - (var(--configured--dragarea_height, 10px) + 45px) + ) !important; +} diff --git a/mods/tweaks/mod.js b/mods/tweaks/mod.js index 0c538fb..7d7e839 100644 --- a/mods/tweaks/mod.js +++ b/mods/tweaks/mod.js @@ -22,6 +22,9 @@ module.exports = { used to drag/move the window.`, type: 'input', value: 15, + platformOverwrite: { + darwin: 0, + }, }, { key: 'responsive_breakpoint', diff --git a/mods/weekly-view/mod.js b/mods/weekly-view/mod.js index 4599e8e..d21abbd 100644 --- a/mods/weekly-view/mod.js +++ b/mods/weekly-view/mod.js @@ -31,7 +31,7 @@ module.exports = { document .querySelectorAll('.notion-collection-view-select') .forEach((collection_view) => { - if (collection_view.innerText != 'weekly') return; + if (collection_view.innerText.toLowerCase() !== 'weekly') return; const days = collection_view.parentElement.parentElement.parentElement.parentElement.getElementsByClassName( 'notion-calendar-view-day' ), diff --git a/package.json b/package.json index a71d9c9..9e121d2 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "scripts": { "test": "echo \"no test specified\"", "postinstall": "node bin.js apply -y", - "preuninstall": "node bin.js remove" + "preuninstall": "node bin.js remove -n" }, "repository": { "type": "git", diff --git a/pkg/helpers.js b/pkg/helpers.js index 46dc300..b3d4872 100644 --- a/pkg/helpers.js +++ b/pkg/helpers.js @@ -133,10 +133,18 @@ function getEnhancements() { ) throw Error; mod.defaults = {}; - for (let opt of mod.options || []) - mod.defaults[opt.key] = Array.isArray(opt.value) - ? opt.value[0] - : opt.value; + for (let opt of mod.options || []) { + if ( + Object.keys(opt.platformOverwrite || {}).some( + (platform) => process.platform === platform + ) + ) { + mod.defaults[opt.key] = opt.platformOverwrite[process.platform]; + } else + mod.defaults[opt.key] = Array.isArray(opt.value) + ? opt.value[0] + : opt.value; + } modules.IDs.push(mod.id); modules.loaded.push({ ...mod,