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: 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.

View File

@ -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

View File

@ -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 ? `<img src="${icon.getAttribute('src')}">` : '') +
(icon
? icon.getAttribute('src')
? `<img src="${icon.getAttribute('src')}">`
: `${icon.getAttribute('aria-label')} `
: '') +
(text
? text.innerText
? text.innerText || 'Untitled'
: [
setTimeout(() => __electronApi.setWindowTitle(title), 250),
title,

View File

@ -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');

View File

@ -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',

View File

@ -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');
});

View File

@ -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';
});
},
},
};

View File

@ -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;
}

View File

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

View File

@ -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'
),

View File

@ -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",

View File

@ -133,10 +133,18 @@ function getEnhancements() {
)
throw Error;
mod.defaults = {};
for (let opt of mod.options || [])
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,