From 29ef9a57b8a0e34489bb28f205e9ef36bb0bb07f Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Wed, 28 Oct 2020 12:19:39 +1100 Subject: [PATCH 1/6] platform-specific option overrides for features not required on macOS --- CHANGELOG.md | 1 + CONTRIBUTING.md | 14 +++++++++----- mods/core/enhancerMenu.js | 7 +++++++ mods/core/mod.js | 6 ++++++ mods/tweaks/mod.js | 3 +++ package.json | 2 +- pkg/helpers.js | 16 ++++++++++++---- 7 files changed, 39 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ff41253..7c38911 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -25,6 +25,7 @@ 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. - 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. 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/enhancerMenu.js b/mods/core/enhancerMenu.js index 7b3b706..7242f03 100644 --- a/mods/core/enhancerMenu.js +++ b/mods/core/enhancerMenu.js @@ -587,6 +587,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/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/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, From eeb83a14e0703925b69a01498d2b32f9b56bceaa Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Wed, 28 Oct 2020 17:50:55 +1100 Subject: [PATCH 2/6] #177 made extra padding at the bottom in focus mode toggleable --- CHANGELOG.md | 7 ++----- mods/focus-mode/mod.js | 20 +++++++++++++++++++- mods/focus-mode/styles.css | 22 ++++++++++++---------- 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c38911..6963c51 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ a flexibility update. - 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. @@ -69,11 +70,7 @@ a fork of notion-deb-builder that does generate an app.asar has been created and // todo -MACOS SPECIFIC FIXES - -- close to tray: perma-true -- frameless mode: perma-false -- open ext. menu hotkey not working? +- open ext. menu hotkey not working on macOS? ### v0.9.1 (2020-09-26) 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; +} From 9e1417ac3ee23c24a5723822b945c9a7aa75f2bb Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 1 Nov 2020 00:03:18 +1100 Subject: [PATCH 3/6] make ctrl+f popover shadow less extreme --- CHANGELOG.md | 1 + mods/core/client.js | 16 +++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 6963c51..f7ed0ec 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ 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. - tweak: sticky table/list rows. - theme: "material ocean" = an oceanic colour palette. - theme: "dracula" = a theme based on the popular dracula color palette diff --git a/mods/core/client.js b/mods/core/client.js index 46142a8..28d5f73 100644 --- a/mods/core/client.js +++ b/mods/core/client.js @@ -117,22 +117,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, }); } From 667c727ac9a7e713cba202130764d9f84d70649e Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 1 Nov 2020 12:04:04 +1100 Subject: [PATCH 4/6] fix menu hotkey + tab title emojis on macOS --- CHANGELOG.md | 4 ---- mods/core/client.js | 16 ++++++++++++++-- mods/core/enhancerMenu.js | 6 +++++- mods/core/render.js | 6 +++++- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f7ed0ec..44de7a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -69,10 +69,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 - -- open ext. menu hotkey not working on macOS? - ### v0.9.1 (2020-09-26) - bugfix: font chooser will continue iterating through fonts after encountering a blank option. diff --git a/mods/core/client.js b/mods/core/client.js index 28d5f73..77b1900 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 @@ -214,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') ); @@ -232,7 +240,11 @@ module.exports = (store, __exports) => { ), text = $container.querySelector('[placeholder="Untitled"]'); title = - (icon ? `` : '') + + (icon + ? icon.getAttribute('src') + ? `` + : `${icon.getAttribute('aria-label')} ` + : '') + (text ? text.innerText : [ diff --git a/mods/core/enhancerMenu.js b/mods/core/enhancerMenu.js index 7242f03..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 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'); }); From 5ac7e521b61393e248395a53ac7b80dd9500cd29 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 1 Nov 2020 12:16:31 +1100 Subject: [PATCH 5/6] fix #183 make weekly calendar view name case insensitive --- CHANGELOG.md | 1 + mods/weekly-view/mod.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 44de7a3..aaff098 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -50,6 +50,7 @@ a flexibility update. - 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 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' ), From 8e2087d2fde803a2fefb27df43d2df897ef18b92 Mon Sep 17 00:00:00 2001 From: dragonwocky Date: Sun, 1 Nov 2020 12:30:10 +1100 Subject: [PATCH 6/6] show 'untitled' for new pages instead of empty space --- mods/core/client.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mods/core/client.js b/mods/core/client.js index 77b1900..0ddafe2 100644 --- a/mods/core/client.js +++ b/mods/core/client.js @@ -246,7 +246,7 @@ module.exports = (store, __exports) => { : `${icon.getAttribute('aria-label')} ` : '') + (text - ? text.innerText + ? text.innerText || 'Untitled' : [ setTimeout(() => __electronApi.setWindowTitle(title), 250), title,