This commit is contained in:
runargs 2020-10-31 22:49:10 -04:00
commit 4bf329f390
12 changed files with 106 additions and 44 deletions

View File

@ -25,6 +25,8 @@ a flexibility update.
- improved: overwrite `app.asar.bak` if already exists (e.g. for app updates). - improved: overwrite `app.asar.bak` if already exists (e.g. for app updates).
- improved: additional menu option descriptions on hover. - improved: additional menu option descriptions on hover.
- improved: listen to prefers-color-scheme to better change theme in night shift. - 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: removed messenger emoji set as the provider no longer supports it.
- bugfix: remove shadow around light mode board headers. - bugfix: remove shadow around light mode board headers.
- bugfix: properly detect/respond to `EACCES`/`EBUSY` errors. - 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: keep "empty" top bar visible in the menu.
- bugfix: set NSRequiresAquaSystemAppearance to false in /Applications/Notion.app/Contents/Info.plist - bugfix: set NSRequiresAquaSystemAppearance to false in /Applications/Notion.app/Contents/Info.plist
so system dark/light mode can be properly detected. 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. - tweak: sticky table/list rows.
- theme: "material ocean" = an oceanic colour palette. - theme: "material ocean" = an oceanic colour palette.
- theme: "dracula" = a theme based on the popular dracula color 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. 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) ### v0.9.1 (2020-09-26)
- bugfix: font chooser will continue iterating through fonts after encountering a blank option. - bugfix: font chooser will continue iterating through fonts after encountering a blank option.

View File

@ -25,20 +25,24 @@ join the [discord server](https://discord.gg/sFWPXtA).
## testing ## testing
download: first, remove any other installations of the enhancer: `npm remove -g notion-enhancer`
to download and install the latest code, run:
```sh ```sh
git clone https://github.com/dragonwocky/notion-enhancer git clone https://github.com/dragonwocky/notion-enhancer
cd notion-enhancer cd notion-enhancer
git checkout dev git checkout dev
npm link 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: ```sh
i don't have the experience/skill with them yet to use them effectively. notion-enhancer remove -n
if you can add some for your code, though, go ahead! npm unlink
```
## conventions ## conventions

View File

@ -25,7 +25,11 @@ module.exports = (store, __exports) => {
const hotkey = toKeyEvent(store().menu_toggle); const hotkey = toKeyEvent(store().menu_toggle);
let triggered = true; let triggered = true;
for (let prop in hotkey) 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 (triggered) electron.ipcRenderer.send('enhancer:open-menu');
if (tabsEnabled) { if (tabsEnabled) {
// switch between tabs via key modifier // switch between tabs via key modifier
@ -117,22 +121,20 @@ module.exports = (store, __exports) => {
? 'dark' ? 'dark'
: 'light', : 'light',
'colors': { 'colors': {
'white': getStyle(`--theme--option_active-color`), 'white': getStyle('--theme--option_active-color'),
'blue': getStyle(`--theme--option_active-background`), 'blue': getStyle('--theme--option_active-background'),
}, },
'borderRadius': 3, 'borderRadius': 3,
'textColor': getStyle(`--theme--text`), 'textColor': getStyle('--theme--text'),
'popoverBackgroundColor': getStyle(`--theme--card`), 'popoverBackgroundColor': getStyle('--theme--card'),
'popoverBoxShadow': `0 0 0 1px ${getStyle( 'popoverBoxShadow': getStyle('--theme--box-shadow_strong'),
`--theme--overlay`
)}, 0 3px 6px ${getStyle(`--theme--overlay`)}`,
'inputBoxShadow': `box-shadow: ${getStyle( 'inputBoxShadow': `box-shadow: ${getStyle(
`--theme--primary` `--theme--primary`
)} 0px 0px 0px 1px inset, ${getStyle( )} 0px 0px 0px 1px inset, ${getStyle(
`--theme--primary_hover` `--theme--primary_hover`
)} 0px 0px 0px 2px !important`, )} 0px 0px 0px 2px !important`,
'inputBackgroundColor': getStyle(`--theme--main`), 'inputBackgroundColor': getStyle('--theme--main'),
'dividerColor': getStyle(`--theme--table-border`), 'dividerColor': getStyle('--theme--table-border'),
'shadowOpacity': 0.2, 'shadowOpacity': 0.2,
}); });
} }
@ -216,6 +218,10 @@ module.exports = (store, __exports) => {
if (tabsEnabled) { if (tabsEnabled) {
let tab_title = ''; let tab_title = '';
if (process.platform === 'darwin')
document
.querySelector('.notion-sidebar [style*="37px"]:empty')
.remove();
const TITLE_OBSERVER = new MutationObserver(() => const TITLE_OBSERVER = new MutationObserver(() =>
__electronApi.setWindowTitle('notion.so') __electronApi.setWindowTitle('notion.so')
); );
@ -234,9 +240,13 @@ module.exports = (store, __exports) => {
), ),
text = $container.querySelector('[placeholder="Untitled"]'); text = $container.querySelector('[placeholder="Untitled"]');
title = title =
(icon ? `<img src="${icon.getAttribute('src')}">` : '') + (icon
? icon.getAttribute('src')
? `<img src="${icon.getAttribute('src')}">`
: `${icon.getAttribute('aria-label')} `
: '') +
(text (text
? text.innerText ? text.innerText || 'Untitled'
: [ : [
setTimeout(() => __electronApi.setWindowTitle(title), 250), setTimeout(() => __electronApi.setWindowTitle(title), 250),
title, title,

View File

@ -131,7 +131,11 @@ window['__start'] = async () => {
const hotkey = toKeyEvent(coreStore().menu_toggle); const hotkey = toKeyEvent(coreStore().menu_toggle);
let triggered = true; let triggered = true;
for (let prop in hotkey) 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')) if (triggered || ((event.ctrlKey || event.metaKey) && event.key === 'w'))
electron.remote.getCurrentWindow().close(); electron.remote.getCurrentWindow().close();
// focus search // focus search
@ -587,6 +591,13 @@ window['__start'] = async () => {
const $options = mod.elem.querySelector('.options'); const $options = mod.elem.querySelector('.options');
if ($options) if ($options)
for (const opt of mod.options) { for (const opt of mod.options) {
if (
Object.keys(opt.platformOverwrite || {}).some(
(platform) => process.platform === platform
)
) {
continue;
}
const $opt = createOption(opt, mod.id); const $opt = createOption(opt, mod.id);
if (opt.type === 'color') { if (opt.type === 'color') {
const $preview = $opt.querySelector('input'); const $preview = $opt.querySelector('input');

View File

@ -46,6 +46,9 @@ module.exports = {
it can be re-shown by clicking the tray icon or using the hotkey.`, it can be re-shown by clicking the tray icon or using the hotkey.`,
type: 'toggle', type: 'toggle',
value: true, value: true,
platformOverwrite: {
darwin: true,
},
}, },
{ {
key: 'frameless', key: 'frameless',
@ -53,6 +56,9 @@ module.exports = {
description: `replace the native titlebar with buttons inset into the app.`, description: `replace the native titlebar with buttons inset into the app.`,
type: 'toggle', type: 'toggle',
value: true, value: true,
platformOverwrite: {
darwin: false,
},
}, },
{ {
key: 'tiling_mode', key: 'tiling_mode',

View File

@ -994,7 +994,11 @@ module.exports = (store, __exports) => {
const hotkey = toKeyEvent(store().menu_toggle); const hotkey = toKeyEvent(store().menu_toggle);
let triggered = true; let triggered = true;
for (let prop in hotkey) 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 (triggered) electron.ipcRenderer.send('enhancer:open-menu');
}); });

View File

@ -13,6 +13,24 @@ module.exports = {
name: 'focus mode', name: 'focus mode',
desc: desc:
'hide the titlebar/menubar if the sidebar is closed (will be shown on hover).', 'hide the titlebar/menubar if the sidebar is closed (will be shown on hover).',
version: '0.1.1', version: '0.2.0',
author: 'arecsu', 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';
});
},
},
}; };

View File

@ -5,16 +5,6 @@
* under the MIT license * 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 { .notion-sidebar-container[style*='width: 0px;'] + .notion-frame .notion-topbar {
opacity: 0 !important; opacity: 0 !important;
transition: opacity 200ms ease-in-out !important; transition: opacity 200ms ease-in-out !important;
@ -24,3 +14,15 @@
.notion-topbar:hover { .notion-topbar:hover {
opacity: 1 !important; 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;
}

View File

@ -22,6 +22,9 @@ module.exports = {
used to drag/move the window.`, used to drag/move the window.`,
type: 'input', type: 'input',
value: 15, value: 15,
platformOverwrite: {
darwin: 0,
},
}, },
{ {
key: 'responsive_breakpoint', key: 'responsive_breakpoint',

View File

@ -31,7 +31,7 @@ module.exports = {
document document
.querySelectorAll('.notion-collection-view-select') .querySelectorAll('.notion-collection-view-select')
.forEach((collection_view) => { .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( const days = collection_view.parentElement.parentElement.parentElement.parentElement.getElementsByClassName(
'notion-calendar-view-day' 'notion-calendar-view-day'
), ),

View File

@ -9,7 +9,7 @@
"scripts": { "scripts": {
"test": "echo \"no test specified\"", "test": "echo \"no test specified\"",
"postinstall": "node bin.js apply -y", "postinstall": "node bin.js apply -y",
"preuninstall": "node bin.js remove" "preuninstall": "node bin.js remove -n"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@ -133,10 +133,18 @@ function getEnhancements() {
) )
throw Error; throw Error;
mod.defaults = {}; mod.defaults = {};
for (let opt of mod.options || []) for (let opt of mod.options || []) {
mod.defaults[opt.key] = Array.isArray(opt.value) if (
? opt.value[0] Object.keys(opt.platformOverwrite || {}).some(
: opt.value; (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.IDs.push(mod.id);
modules.loaded.push({ modules.loaded.push({
...mod, ...mod,