This commit is contained in:
dragonwocky 2021-11-06 14:26:35 +11:00
parent a362f804d9
commit affa314f08
Signed by: dragonwocky
GPG Key ID: 86DFC3C312A56010
74 changed files with 651 additions and 12735 deletions

105
.gitignore vendored
View File

@ -1,104 +1 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
node_modules/*

View File

@ -1,3 +0,0 @@
{
"singleQuote": true
}

View File

@ -1,344 +0,0 @@
# changelog
**potential future features (not confirmed)**
- [highlight/mark viewer](https://chrome.google.com/webstore/detail/notion%2B-mark-manager/hipgmnlpnimedfepbfbfiaobohhffcfc)
- [advanced math editor](https://github.com/Manueloccorso/NotionMathEditor_BrowserExtension)
### v0.10.2 (2020-12-05)
again, an emergency release for bugfixes.
not properly documented and new features have not yet been fully reviewed/edited.
- new: side panel - adds an extra sidebar on the right for use by other mods,
toggleable with `ctrl+shift+backslash`.
- improved: notion icons uses spritesheets for faster loading of icons.
- improved: icon sets can be hidden/toggled.
- improved: toggles in the enhancer menu follow the same style as notion's toggles.
- improved: separate quote font variable & option in the font chooser mod (`--theme_[dark|light]--font_quote`).
- improved: option to hide the "page details" text for the word counter extension.
- bugfix: notion icons tab is now visible in fullpage databases.
- bugfix: code line numbers handles wrapped code blocks.
- bugfix: file explorer no longer opens when enhancer menu is opened.
- bugfix: enable the remote module in webviews (windows/tabs) for compatibility with the
updated version of electron used by new notion builds (>= 2.0.10).
- bugfix: add support for enhancing an `app` folder if there is no `app.asar` file present.
- extension: "outliner" = table of contents in right sidebar.
- extension: "panel sites" = embed sites on the site panel.
- extension: "indentation lines" = adds vertical relationship lines to make list trees easier to follow.
- extension: "truncated table titles" = see the full text of the truncated table titles on hover over.
> 📥 `npm i -g notion-enhancer@0.10.2`
### v0.10.1 (2020-11-18)
essentially a prerelease for v0.11.0: pushed out for urgent bugfixes during
exam/study weeks when there's no time to code a full release.
note that this means new features have not yet been fully documented and
may not be fully ready for ideal use yet. however, things overall will
work more reliably than v0.10.0.
- new: different css entrypoints for different components (tabs, menu, app).
- improved: use an svg for the scroll-to-top button.
- improved: use a better-matching icon and add transitions to the property layout toggle.
- improved: themes are directly applied to tabs and menu rather than sync-ed between (infinite loading).
- improved: error message "is notion running?" --> clearer "make sure notion isn't running!"
- improved: auto-shrink system for tabs (max of 15 open in a window).
- bugfix: disable fadein of selected block halo with snappy transitions.
- bugfix: increase contrast of `--theme_dark--interactive_hover` in dark+ and dracula.
- bugfix: tabs are focused properly for input.
- bugfix: keyboard shortcut listeners are stricter so they don't conflict.
- bugfix: dots indicating draggability are no longer next to the tabs mod in the menu.
- bugfix: prevent empty hotkeys from triggering every keypress.
- bugfix: don't try loading an empty default page url (infinite loading).
- bugfix: remove `* { z-index: 1}` rule so format dropdowns in table view can be opened.
- extension: "topbar icons" = replaces the topbar buttons with icons.
- extension: "code line numbers" = adds line numbers to code blocks.
- extension: "notion icons" = use custom icon sets directly in notion.
- tweak: vertical indentation/relationship lines for lists.
- tweak: scroll database toolbars horizontally if partially hidden.
- tweak: condense bullet points (decrease line spacing).
> 📥 `npm i -g notion-enhancer@0.10.1`
### v0.10.0 (2020-11-02)
a flexibility update.
- new: mods can be reordered in the menu to control what order styling/scripts are added/executed in.
higher up on the list = higher priority of application = loaded last in order to override others.
(excluding the core, which though pinned to the top of the list is always loaded first so theming
variables can be modified.)
- new: relaunch button in tray menu.
- new: a core mod option for a default page id/url (all new windows will load it instead of the
normal "most recent" page).
- new: css variables for increasing line spacing/paragraph margins.
- new: patch the notion:// url scheme/protocol to work on linux.
- new: menu shows theme conflicts + a core mod option to auto-resolve theme conflicts.
- new: a `-n` cli option.
- improved: menu will now respect integrated titlebar setting.
- improved: use keyup listeners instead of a globalShortcut for the enhancements menu toggle.
- 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.
- bugfix: night shift checks every interaction,
will respond to system changes without any manual changes.
- bugfix: toc blocks can have text colours.
- bugfix: bypass preview extension works with the back/forward keyboard shortcuts.
- bugfix: (maybe) fix csp issues under proxy.
- bugfix: remove focus mode footer from neutral theme + better contrast in calendar views.
- bugfix: improvements to the colour theming, particularly to make real- and fake-light/dark
modes (as applied by the night shift extension) look consistent.
relevant variables (assuming all are prefixed by `--theme_[dark|light]--`):
`box-shadow`, `box-shadow_strong`, `select_input`, and `ui-border`
- bugfix: font sizing applied to overlays/previews.
- bugfix: removed typo in variable name for brown text.
- bugfix: primary-colour text (mainly in "add a \_" popups) is now properly themed.
- bugfix: right-to-left extension applies to text in columns.
- bugfix: block text colour applies to text with backgrounds.
- bugfix: font applied to wrong mode with littlepig dark.
- 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.
- bugfix: re-show hidden windows when clicking on the dock.
- tweak: sticky table/list rows.
- theme: "material ocean" = an oceanic colour palette.
- theme: "cherry cola" = a delightfully plummy, cherry cola flavored theme.
- theme: "dracula" = a theme based on the popular dracula color palette
originally by zeno rocha and friends.
- extension: "tabs" = have multiple notion pages open in a single window. tabs can be controlled
with keyboard shortcuts and dragged/reordered within/between windows.
- extension: "scroll to top" = add an arrow above the help button to scroll back to the top of a page.
- extension: "tweaks" = common style/layout changes. includes:
- new: make transitions snappy/0s.
- new: in-page columns are disabled/wrapped and pages are wider when
the window is narrower than 600px for improved responsiveness.
- new: thicker bold text for better visibility.
- new: more readable line spacing.
- moved: smooth scrollbars.
- moved: change dragarea height.
- moved: hide help.
a fork of notion-deb-builder that does generate an app.asar has been created and is once again supported.
> 📥 `npm i -g notion-enhancer@0.10.0`
### v0.9.1 (2020-09-26)
- bugfix: font chooser will continue iterating through fonts after encountering a blank option.
- bugfix: block indents are no longer overriden.
- bugfix: neutral does not force full width pages.
- bugfix: bypass preview extension works with the back/forward arrows.
- bugfix: check all views on a page for a weekly calendar.
- bugfix: emoji sets no longer modifies the user agent = doesn't break hotkeys.
> 📥 `npm i -g notion-enhancer@0.9.1`
### v0.9.0 (2020-09-20)
a feature and cleanup update.
- improved: halved the number of css rules used -> much better performance.
- improved: font imports must be define in the `mod.js` so that they can also be used in
the enhancements menu.
- improved: tiling window-manager support (can hide titlebars entirely without dragarea/buttons).
- improved: extensions menu search is now case insensitive and includes options, inputs and versions.
the search box can also for focused with `CMD/CTRL+F`.
- improved: extensions menu filters shown either a ✓ or × to help understand the current state.
- improved: added individual text-colour rules for different background colours.
- improved: added variables for callout colouring.
- improved: replaced with `helpers.getNotion()` with the constant `helpers.__notion` to reduce
repeated function calls.
- improved: added variables for page width.
- improved/bugfix: emoji sets extension should now work on macOS and will change user agent to use
real emojis instead of downloading images when system default is selected.
- bugfix: enhancer settings should no longer reset on update (though this will not have
effect until the release after this one).
- bugfix: blue select tags are no longer purple.
- bugfix: page titles now respond to small-text mode.
- bugfix: weekly calendar view height is now sized correctly according to its contents.
- bugfix: made the open enhancements menu hotkey configurable and changed the default to `ALT+E`.
to remove conflict with the inline code highlight shortcut.
- bugfix: update property-layout to match notion changes again.
- bugfix: updated some of the tweak styling to match notion changes.
- bugfix: block-level text colours are now changed properly.
- bugfix: do not require data folder during installation, to prevent `sudo` attempting to
create it in `/var/root/`.
- bugfix: bullet points/checkboxes will now align properly in the right-to-left extension.
- themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text.
- extension: "font chooser" = customize fonts. for each option, type in the name of the font you would like to use,
or leave it blank to not change anything.
- extension: "always on top" = add an arrow/button to show the notion window on top of other windows
even if it's not focused.
- extension: "calendar scroll" = add a button to scroll down to the current week in fullpage/infinite-scroll calendars.
- extension: "hide help button" = hide the help button if you don't need it.
- extension: "bypass preview" = go straight to the normal full view when opening a page.
- extension: "word counter" = add page details: word/character/sentence/block count & speaking/reading times.
notion-deb-builder has been discovered to not generate an app.asar and so is no longer supported.
> 📥 `npm i -g notion-enhancer@0.9.0`
### v0.8.5 (2020-08-29)
- bugfix: separate text highlight and select tag variables.
- bugfix: bypass CSP for the `enhancement://` protocol - was failing on some platforms?
> 📥 `npm i -g notion-enhancer@0.8.5`
### v0.8.4 (2020-08-29)
- bugfix: property-layout now works consistently with or without a banner.
> 📥 `npm i -g notion-enhancer@0.8.4`
### v0.8.3 (2020-08-29)
previous release was a mistake: it did as intended on linux, but broke windows.
this should achieve the same thing in a more compatible way.
> 📥 `npm i -g notion-enhancer@0.8.3`
### v0.8.2 (2020-08-28)
some things you just can't test until production... fixed the auto-installer
to use `./bin.js` instead of `notion-enhancer`
> 📥 `npm i -g notion-enhancer@0.8.2`
### v0.8.1 (2020-08-28)
a clarity and stability update.
- improved: more informative cli error messages (original ones can be accessed with the `-d/--dev` flag).
- bugfix: gallery variable didn't apply on fullpage.
- bugfix: date picker hid current date number.
- bugfix: small-text pages should now work as expected.
- bugfix: padding issues in page previews.
- bugfix: property-layout extension had been broken by internal notion changes.
- bugfix: linux installer path typo.
- bugfix: caret-color was being mistaken for color and block-level text colouring was broken.
- improved: auto-application on install.
> 📥 `npm i -g notion-enhancer@0.8.1`
### v0.8.0 (2020-08-27)
complete rewrite with node.js.
- new: simpler cli installation system (inc. commands: `apply`, `remove`, and `check`).
- new: mod loading system (easier to create new mods, adds to notion rather than overwriting).
- new: mod configuration menu.
- improved: more theming variable coverage - inc. light theme and sizing/spacing.
- bugfix: non-reproducable errors with python.
- bugfix: better launcher patching on linux.
- bugfix: fix frameless window issue introduced by notion desktop 2.0.9.
- extension: "custom inserts" = link files for small client-side tweaks.
- extension: "bracketed links" = render links surrounded with \[\[brackets]] instead of underlined.
- extension: "focus mode" = hide the titlebar/menubar if the sidebar is closed (will be shown on hover).
- theme: "dark+" = a vivid-colour near-black theme.
- theme: "neutral" = smoother colours and fonts, designed to be more pleasing to the eye.
- theme: "gameish" = a purple, "gamer-styled" theme with a blocky-font.
- theme: "pastel dark" = a smooth-transition true dark theme with a hint of pastel.
- extension: "emoji sets" = pick from a variety of emoji styles to use.
- extension: "night shift" = sync dark/light theme with the system (overrides normal theme setting).
- extension: "right-to-left" = enables auto rtl/ltr text direction detection. (ported from [github.com/obahareth/notion-rtl](https://github.com/obahareth/notion-rtl).)
- extension: "weekly view" = calendar views named "weekly" will show only the 7 days of this week. (ported from [github.com/adihd/notionweeklyview](https://github.com/adihd/notionweeklyview).)]
- extension: "property layout" = auto-collapse page properties that usually push down page content. (ported from [github.com/alexander-kazakov/notion-layout-extension](https://github.com/alexander-kazakov/notion-layout-extension).)
> 📥 `npm i -g notion-enhancer@0.8.0`
### v0.7.0 (2020-07-09)
- new: tray option to use system default emojis (instead of twitter's emojiset).
- new: mac support (identical functionality to other platforms with the
exception of the native minimise/maximise/close buttons being kept, as they integrate
better with the OS while not being out-of-place in notion).
- new: notion-deb-builder support for linux.
- new: an alert will be shown if there is an update available for the enhancer.
- improved: replaced button symbols with svgs for multi-platform support.
- improved: window close button is now red on hover (thanks to [@torchatlas](https://github.com/torchatlas)).
- bugfix: `cleaner.py` patched for linux.
- bugfix: tray now operates as expected on linux.
- bugfix: odd mix of `\\` and `/` being used for windows filepaths.
- bugfix: app no longer crashes when sidebar is toggled.
> 📥 [notion-enhancer.v0.7.0.zip](https://github.com/notion-enhancer/notion-enhancer/archive/v0.7.0.zip)
### v0.6.0 (2020-06-30)
- style: custom fonts.
- style: font resizing.
- style: hide discussions (thanks to [u/Roosmaryn](https://www.reddit.com/user/Roosmaryn/)).
- new: custom colour theming, demonstrated via the dark+ theme.
- new: linux support (thanks to [@Blacksuan19](https://github.com/Blacksuan19)).
- improved: if hotkey is pressed while notion is unfocused, it will bring it to the front rather than hiding it.
- improved: stop window buttons breaking at smaller widths.
- improved: more obviously visible drag area.
- bugfix: specify UTF-8 encoding to prevent multibyte/gbk codec errors (thanks to [@etnperlong](https://github.com/etnperlong)).
> 📥 [notion-enhancer.v0.6.0.zip](https://github.com/notion-enhancer/notion-enhancer/archive/v0.6.0.zip)
### v0.5.0 (2020-05-23)
- new: running from the wsl.
- new: reload window with f5.
- improved: code has been refactored and cleaned up,
inc. file renaming and a `customiser.py` that doesn't require
a run of `cleaner.py` to build modifications.
improved: scrollbar colours that fit better with notion's theming.
- bugfix: un-break having multiple notion windows open.
> 📥 [notion-enhancer.v0.5.0.zip](https://github.com/notion-enhancer/notion-enhancer/archive/v0.5.0.zip)
**development here taken over by [@dragonwocky](https://github.com/dragonwocky).**
**the ~~crossed out~~ features below are no longer features included by default,**
**but can still easily be added as [custom tweaks](TWEAKS.md).**
### v0.4.1 (2020-02-13)
- bugfix: wider table & the "+" button not working in database pages.
> 📥 [notion-enhancer.v4.1.zip](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/d239a3cf-d553-4ef3-ab04-8b47892d9f9a/Notion_Customization_v4.1.zip)
### v0.4.0
- new: tray icon.
- new: app startup options (+ saving).
- new: `Reset.py`
- improved: better output from `Customization Patcher.py`.
- bugfix: wider tables in "short page" mode.
- bugfix: unclickable buttons/draggable area (of titlebar).
### v0.3.0
- new: show/hide window hotkey.
- new: app startup options.
- ~~style: smaller table icons.~~
> 📥 [notion-enhancer.v3.zip](https://s3-us-west-2.amazonaws.com/secure.notion-static.com/b01aa446-5727-476a-a25e-395472bfb1be/NotionScriptsV3.zip)
### v0.2.0
- new: light/dark theme support for window control buttons + scrollbars.
- new: custom styles directly linked to the enhancer resources + compatible with web version.
- ~~improved: making table column width go below 100px.~~
### v0.1.0
- new: custom window control buttons.
- removed: default titlebar/menubar.
- ~~removed: huge padding of board view.~~
- ~~removed: huge padding of table view.~~
- ~~optional: making table column width go below 100px.~~
- ~~style: thinner cover image + higher content block.~~
- style: scrollbars.

View File

@ -1,111 +0,0 @@
# contributing
the enhancer is a tool for the community, so who best to build it but the community?
these guidelines are designed for smooth communication, management and development on this project.
following them shows respect to the developer/s spending their free time on it, and makes it easiest for them to improve the tool.
**found a bug / something isn't working as expected?** create a
[bug report](https://github.com/notion-enhancer/notion-enhancer/issues/new?labels=bug&template=bug-report.md).
> SECURITY ISSUE? (e.g. PERSONAL/NOTION DATA BEING INTERFERED WITH)
> EMAIL ME INSTEAD: [thedragonring.bod@gmail.com](mailto:thedragonring.bod@gmail.com)
**have a cool new feature idea / there's something you just wish you could do?** submit a
[feature proposal](https://github.com/notion-enhancer/notion-enhancer/issues/new?labels=enhancement&template=feature-proposal.md).
> enhancements are applied only locally -
> features should be designed only to improve the user experience.
**know your way around notion/electron/js/css and have some code to contribute?** great! read below for guidelines
on how to create a helpful pull request and what happens with your code afterwards. it's probably also helpful to
join the [discord server](https://discord.gg/sFWPXtA).
**for information on how to actually create a theme or module with the notion-enhancer api, check the [docs](DOCUMENTATION.md).**
## testing
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/notion-enhancer/notion-enhancer
cd notion-enhancer
git checkout dev
npm link
notion-enhancer apply -y
```
to update the dev build, go into the downloaded folder and run `git pull`. (make sure any work-in-progress themes etc. are copied somewhere else safely first.)
to remove the dev build, go into the downloaded folder and run:
```sh
notion-enhancer remove -n
npm unlink
```
## conventions
the enhancer is a **core** extended by included **modules**.
the core can be further split into the **installer** and the **modloader**.
modules are either **extensions** or **themes**.
each module is separately versioned, following the [semver](https://semver.org/) scheme.
depending on the content and scale of a contribution, it may constitute an update on its own or may be merged into a larger update.
to keep a consistent & informative code style it is preferred to name variables with
`snake_case`, functions/methods with `camelCase`, and classes with `PascalCase`.
if a variable is a reference to a DOM element, it may be helpful to prefix it with a `$`.
some variables beginning with a double underscore are `__folder` paths and `ALL_CAPS` variables
are constant. this is not required, but these styles should not be used for any other purpose.
the master branch is kept consistent with the current release,
so all changes should be made to the dev branch.
## review
active core devs will manually look through each pull request and communicate with contributors before merging to
make sure it is:
**a) safe.** system details (e.g. IP, clipboard) + notion user data are considered private unless directly shared by the user.
none of this should be accessed or transmitted to an external server.
**b) functional.** is there a better way to do this? can extra dependencies be removed or replaced by newer web technologies?
how can this be made as user-friendly as possible?
**c) bug-free.** where possible, code should be tested on a variety of platforms in a variety of situations so it can be
confirmed that it won't break anything for the user and is robust enough to handle use by both
power users and non-tech-savvy users.
## translating
future versions of the enhancer will have multi-language support.
if you are willing to help with translation, let me know and i'll contact you when i'm ready.
## licensing
this project is distributed under the [MIT](https://choosealicense.com/licenses/mit/) license.
the project as a whole is copyrighted by core devs in the [LICENSE](LICENSE) file.
when modifying a file, add your copyright to it in the format:
```
/*
* module or project name
* (c) year name <email> (website)
* under the MIT license
*/
```
all code contributed to this repository remains attributed to the contributor,
but full rights are granted for it to be used under the terms of the MIT license.
on the occasion that the contributed code should be removed or overwritten,
the contributor's copyright may be removed from the file.
by opening a pull request in this repository, you agree to the above conditions.
dependencies remain separately licensed to their various authors.

View File

@ -1,217 +0,0 @@
# documentation
the enhancer is essentially a modloader for notion. this document contains the specifications of
how those modules can be made and what they should contain.
this file assumes basic working knowledge of modern javascript and css. since these are the languages
executable within the notion app, these are the languages enhancements must be written in.
want to contribute? check the [contribution guidelines](CONTRIBUTING.md).
for support, join the [discord server](https://discord.gg/sFWPXtA).
## creating a mod
_to understand best how notion's app works, check out [the electron docs](https://www.electronjs.org/docs/),_
_explore the contents of your local extracted `app.asar`, and navigate the html structure with the devtools web inspector._
_look through [the existing modules](mods)_
_for examples of the stuff described below in action._
_at the moment, for ease of development and use (and security assurance), there's no way for users_
_to install their own modules. this means that testing modules requires_
_[running a dev build of the enhancer](CONTRIBUTING.md#testing). a better system is in the works._
_once your mod is working, open a pull request to add it to the enhancer!_
each directory in the `mods` folder is considered a module, with the file entry points `mod.js`,
`variables.css`, `app.css`, `tabs.css` and `menu.css`.
| file | description |
| ------------ | --------------------------------------------------------------------- |
| `mod.js` | **required:** describes the module and contains functional javascript |
| `styles.css` | **optional:** a css file automatically inserted into each app window |
## mod.js
```js
// not valid js!
// a visual representation of the contents/type
// of this file's exported object.
module.exports = {
id: String of uuidv4,
name: String of short_name,
tags?: Array<String> of categories,
desc: String of markdown,
version: String of semver,
author: String of github_username OR {
name: String of author_name,
link: String of url,
avatar: String of image_source,
},
options?: Array<{
key: String,
label: String,
desc?: String,
type: String in ['toggle', 'select', 'input', 'file'],
value: Boolean or Array<String> or String or Number or null,
platformOverwrite?: {
darwin?: Boolean or Array<String> or String or Number or null,
win32?: Boolean or Array<String> or String or Number or null,
linux?: Boolean or Array<String> or String or Number or null,
}
}>,
hacks?: {
[k: 'insert-point' (e.g. 'main/createWindow.js')]: function (
store, // used for configuration and persisting of data (explanation below).
__exports // module.exports of the target file. if you don't understand that, don't use it.
) {}
}
};
```
| key | value | type |
| ------- | ----------------------------------------------------------------------------------------------- | ---------------------- |
| id | **required:** uuidv4 - generate a new one [here](https://www.uuidgenerator.net) | _string_ |
| name | **required:** short name (e.g. `'ocean theme'`) | _string_ |
| tags | **required:** categories/type (e.g. `'extension'`, `'theme'`, `'light'`, `'dark'`) | _array\<string\>_ |
| desc | **optional:** 1-3 sentence description of what the module is/does, with basic markdown support. | _string_ |
| version | **required:** semver (e.g. `'0.3.7'`) | _string_ |
| author | **required:** see below: original extension creator | _string_ or \<object\> |
| options | **optional:** see below: options made available in the enhancer menu (accessible from the tray) | _array\<object\>_ |
| hacks | **optional:** see below: code inserted at various points | _object_ |
> a module that with the primary function of being a hack should be tagged as an extension,
> while a module that has the primary function of adding styles should be tagged as a theme.
#### author
by default this is assumed to be a github username: just pass it as a string and
the link/avatar will be automatically found.
if you'd rather customise this, pass this object:
| key | value | type |
| ------ | ------------------------------------------ | -------- |
| name | **required:** author's (your?) name | _string_ |
| link | **required:** link to the author's profile | _string_ |
| avatar | **required:** url for the author's avatar | _string_ |
#### options
| key | value | type |
| ----------------- | ---------------------------------------------------------------------------------------- | --------------------------- |
| key | **required:** key to save value to the mod `store` | _string_ |
| label | **required:** short description/name of option to be shown in menu | _string_ |
| desc | **optional:** extended information to be shown on hover | _string_ |
| type | **required:** input type (see below) | _string_ |
| extensions | **optional:** allowed file extensions (only use with a file option), e.g. `['js', 'ts']` | _array\<string\>_ |
| value | **optional:** default or possible value/s for option | see below |
| platformOverwrite | **optional:** remove the option from the menu and force a value on a specific platform | _\<object\>_ as shown above |
| type | value |
| ------ | -------------------- |
| toggle | _boolean_ |
| select | _array\<string\>_ |
| input | _string_ or _number_ |
| color | _string_ |
| file | none |
> the file option stores only a filepath, not the file itself.
## hacks
each "hack" is a function taking 2 arguments.
1. the **`store`** argument, which allows access to the module settings/options defined in `mod.js`
(those set in the menu, or used internally by the module). each module store is automatically saved to +
loaded from `~/.notion-enhancer/id.json`.
it should always be called as `store({ defaults })` (not stored in a variable),
but otherwise treated as a normal object to access and set things.
2. the **`__exports`** argument, which is the `module.exports` of the file being modded.
this can be used to call or replace functions from notion.
this hack is applied to whichever file (`.js`-only) is set as the function key. these can be found within the `app` folder.
files under the `main` folder are executed on app launch in a process shared
between all app windows (consider it a backend). files under the `renderer` folder are
executed on window launch in a pre-window process: the client-side javascript
normally expected to run on a webpage.
unless scripts need to change app logic (e.g. to add the tray menu),
they should usually be applied to `renderer/preload.js` to interact
with the app window itself.
e.g.
```js
// sayhi.js
module.exports = function (store, __exports) {
document.addEventListener('readystatechange', (event) => {
if (document.readyState !== 'complete') return false;
console.log(store({ name: 'dragonwocky' }).name);
});
};
// mod.js
module.exports.hacks = {
'renderer/preload.js': require('./sayhi.js'),
};
```
### the `enhancement://` protocol
any files within the `mods` folder can be loaded with the `enhancement://` protocol.
for example, inserting an image from the core mod: `<img src="enhancement://core/image.png">`.
## `variables.css`
**inserted into all windows.**
(put font import statements here too.)
the enhancer has been designed with theming in mind, so as much of notion's colours
and typography as possible and some basic spacing (both for the light and dark themes) have been mapped out
using css variables.
this set of variables is 100% mandatory to use if you wish to use or change anything they handle
(particularly colours). this is necessary to keep all themes consistently working
(e.g. responding properly to light/dark theme changes), and it makes theming a lot easier -
notion's html structure needs some complex selectors to properly modify it,
and it means theme authors don't have to worry about separately updating their theme every time something changes.
the full/up-to-date list of variables and their default values can be found in the
[core `variables.css` file](mods/core/variables.css). each variable is named something along the lines of
`--theme_mode--target_name-property`. still not sure what a variable does? try changing it and seeing what happens.
these are all made possible by the core module. if you believe this set of variables is buggy or lacking in any way,
consider opening a pull request to fix those issues - please do not try and reinvent the wheel unnecessarily.
> ### using variables
>
> variables should be defined per-mode, but used without specifying. for example:
>
> ```css
> :root {
> --theme_dark--main: rgb(5, 5, 5);
> }
> .demo-element {
> background: var(--theme--main);
> }
> ```
>
> this to simplify styling and make it possible for things like the "night shift" module to work,
> by leaving the choice of light/dark theme up to the user and then directing the right values to
> the relevant variables.
## `app.css`
**inserted into the notion app window.**
## `tabs.css`
**inserted into the notion app container for styling tabs.**
## `menu.css`
**inserted into the enhancements menu.**

22
LICENSE
View File

@ -1,22 +0,0 @@
MIT License
Copyright (c) 2020 TarasokUA
Copyright (c) 2020 dragonwocky
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

456
README.md
View File

@ -1,455 +1,3 @@
# <img src="./mods/core/icons/mac+linux.png" height="20px"> notion-enhancer
# notion-enhancer (desktop)
notion.so is a pretty awesome tool already, but there's always room for improvements.
it might just be a preference, it might be something crucial to your setup,
it might be something users have been asking for for a long time,
or it might even be something you haven't realised you need yet
\- there's something that would make your user experience a lot better.
this package is a mod-loader for the desktop app, with custom colour theming and extra feature enhancements.
want to contribute? check out the [contribution guidelines](CONTRIBUTING.md) and the [documentation](DOCUMENTATION.md).
for support, join the [discord server](https://discord.gg/sFWPXtA).
### supported desktop clients
- the [official windows/mac releases](https://notion.so/desktop).
- the arch linux AUR [notion-app](https://aur.archlinux.org/packages/notion-app/) package.
- the linux [notion-app](https://github.com/jaredallard/notion-app) installer.
- the linux [notion-deb-builder](https://github.com/davidbailey00/notion-deb-builder).
outdated notion versions (< 2.0.10) probably won't work.
mobile clients are not supported and due to system limitations/restrictions cannot be.
a chrome extension may be coming soon for web client support.
## installation
> **if you are updating from v0.7.0 or earlier,** things have changed, more information is available
> in this [update guide](UPDATING.md). please read that before following these instructions.
- ensure that no notion windows/processes are running by ending all Notion processes in your task manager.
- `CMD + ALT + ESC` on mac and `CTRL + SHIFT + ESC` on windows/linux to open task manager.
- [install node.js](https://nodejs.org/en/download/)
- you may need to restart your computer.
- notion-enhancer will use node.js, you do not need to interact with it aside from downloading to install notion-enhancer.
- open your computer's terminal, **not the node.js command prompt.**
- **windows 10:** search in your start menu (click windows key or icon in bottom left of screen) for _'cmd'_ or _'command prompt'_.
- **mac:** search in spotlight (magnifying glass in top right of screen) for _'terminal'_.
- type and enter the following line(s) based on your operating system, if there are multiple lines, make sure to enter them _one by one_ .
- **windows 10:**
```
npm i -g notion-enhancer
```
- **mac:** this may ask you to enter your password, instead of hiding your password with \*\*\* symbols, mac terminal hides it by making it invisible. simply type your password and click enter.
```
sudo chmod -R a+wr /usr/local/lib/node_modules
sudo chmod -R a+wr /usr/local/bin
sudo chmod -R a+wr /Applications/Notion.app/Contents/Resources
npm i -g notion-enhancer
```
- **debian/ubuntu, chromeOS, wsl (to modify the win10 app):**
```
bash curl -sL https://deb.nodesource.com setup_current.x | sudo -E bash -
sudo apt-get install -y nodejs
npm i -g notion-enhancer
```
- **arch linux, manjaro:**
- install the [aur package](https://aur.archlinux.org/packages/notion-enhancer) with your aur helper (e.g. `yay -S notion-enhancer`).
### command-line interface
the enhancements should be automatically applied on installation
and automatically removed on uninstallation.
on some platforms this may throw errors if done without
elevated/admin permissions, though, so if it hasn't automatically
installed you will still need to use these commands.
```
Usage:
$ notion-enhancer <command> [options]
Commands:
apply : add enhancements to the notion app
remove : return notion to its pre-enhanced/pre-modded state
check : check the current state of the notion app
For more info, run any command with the `--help` flag:
$ notion-enhancer apply --help
$ notion-enhancer remove --help
$ notion-enhancer check --help
Options:
-y, --yes : skip prompts (may overwrite data)
-n, --no : skip prompts (may cause failures)
-d, --dev : show detailed error messages (for debug purposes)
-h, --help : display usage information
-v, --version : display version number
```
### faq
**when will the update be out?**
i code this in my free time, in-between my other commitments. there are no ETAs.
**the themes aren't working?**
if you pick a dark theme it will only be applied if notion is in dark mode,
and if you pick a light theme it will only work if notion is in light mode.
do `CMD/CTRL+SHIFT+L` to toggle between them.
**is this against notion's terms of service? can i get in trouble for using it?**
definitely not! i contacted their support team to check, and the response was awesome:
> "Thanks for taking the time to share this with us. Userscripts and userstyles are definitely
> cool ideas and would be helpful for many users! ... I'll also share this with the rest of the
> team to take to heart for future improvements."
**how do i uninstall the enhancer?**
run `npm remove -g notion-enhancer`.
## features
most of the enhancer's functionality is split into configurable enhancement modules,
but some basic improvements necessary for things to work are built in by values:
- the notion:// url scheme/protocol is patched to work on linux.
- a tray/menubar icon: links relevant to the enhancer + buttons to manage notion windows.
once applied, modules can be configured via the graphical menu,
which is opened from the tray/menubar icon or with `OPTION/ALT+E`.
![](https://user-images.githubusercontent.com/16874139/97819046-34e8b600-1cfa-11eb-8fa6-a3ad5374cd0b.png)
currently all modules come pre-installed for technical reasons, security assurance, and ease-of-use.
these include:
### notion-enhancer core
**tags:** #core
**description:** the cli, modloader, menu, & tray.
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | extended description | type | values/defaults | platform-specific details |
| ----------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | -------------------------- | ------------------------- |
| auto-resolve theme conflicts | when a theme is enabled any other themes of the same mode (light/dark) will be disabled. | toggle | no | |
| hide app on open | app can be made visible by clicking the tray icon or using the hotkey. | toggle | no | |
| auto-maximise windows | whenever a window is un-hidden or is created it will be maximised. | toggle | no | |
| close window to the tray | pressing the × close button will hide the app instead of quitting it. it can be re-shown by clicking the tray icon or using the hotkey. | toggle | yes | |
| integrated titlebar | replace the native titlebar with buttons inset into the app. | toggle | yes | macOS: forced on |
| tiling window manager mode | completely remove the close/minimise/maximise buttons - this is for a special type of window manager. if you don't understand it, don't use it. | toggle | no | macOS: forced off |
| window display hotkey | used to toggle hiding/showing all app windows. | [accelerator](https://github.com/electron/electron/blob/master/docs/api/accelerator.md) input | `CommandOrControl+Shift+A` | |
| open enhancements menu hotkey | used to toggle opening/closing this menu while notion is focused. | [accelerator](https://github.com/electron/electron/blob/master/docs/api/accelerator.md) input | `Alt+E` | |
| values/defaults page id/url | every new tab/window that isn't opening a url via the notion:// protocol will load this page. to get a page link from within the app, go to the triple-dot menu and click "copy link". leave blank to just load the last page you opened. | text input | `Alt+E` | |
![](https://user-images.githubusercontent.com/16874139/97819249-7a59b300-1cfb-11eb-99fa-de945fe8e3d9.png)
### tabs
**tags:** #core #extension
**description:** have multiple notion pages open in a single window.
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | type | values/defaults |
| --------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
| tab select modifier (key+1, +2, +3, ... +9 and key+left/right arrows) | select | `Alt`, `Command`, `Control`, `Super`, `Alt+Shift`, `Command+Shift`, `Control+Shift`, `Super+Shift` |
| new tab keybinding | [accelerator](https://github.com/electron/electron/blob/master/docs/api/accelerator.md) input | `CommandOrControl+T` |
| close tab keybinding | [accelerator](https://github.com/electron/electron/blob/master/docs/api/accelerator.md) input | `CommandOrControl+W` |
![](https://user-images.githubusercontent.com/16874139/97821456-9dd62b00-1d06-11eb-8c3a-e9f77bbd740e.png)
### tweaks
**tags:** #core #extension
**description:** common style/layout changes.
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | extended description | type | values/defaults | platform-specific details |
| ---------------------------- | ---------------------------------------------------------------------------------------------------------- | ------------ | --------------- | ------------------------- |
| height of frameless dragarea | the rectangle added at the top of a window in "integrated titlebar" mode, used to drag/move the window. | number input | 15 | macOS: forced to 0 |
| width to wrap columns at | the size in pixels below which in-page columns are resized to appear full width so content isn't squished. | number input | 600 | |
| integrated scrollbars | use scrollbars that fit better into notion's ui instead of the default chrome ones. | toggle | yes | |
| snappy transitions | | toggle | no | |
| thicker bold text | | toggle | yes | |
| more readable line spacing | | toggle | no | |
| hide help button | | toggle | no | |
![](https://user-images.githubusercontent.com/16874139/97819829-1638ee00-1cff-11eb-80c6-f270c2ba0f37.png)
### always on top
**tags:** #extension
**description:** add an arrow/button to show the notion window
on top of other windows even if it's not focused.
**author:** [dragonwocky](https://github.com/dragonwocky/)
![](https://user-images.githubusercontent.com/16874139/97820478-79784f80-1d02-11eb-9e32-caac4563d8f0.png)
### bracketed links
**tags:** #extension
**description:** render links surrounded with \[\[brackets]] instead of underlined.
**author:** [arecsu](https://github.com/arecsu/)
![](https://user-images.githubusercontent.com/16874139/97820501-9f9def80-1d02-11eb-8ad8-b1ddf1ed9599.png)
### bypass preview
**tags:** #extension
**description:** go straight to the normal full view when opening a page.
**author:** [dragonwocky](https://github.com/dragonwocky/)
### calendar scroll
**tags:** #extension
**description:** add a button to scroll down to the current week in fullpage/infinite-scroll calendars.
**author:** [dragonwocky](https://github.com/dragonwocky/)
![](https://user-images.githubusercontent.com/16874139/97820611-fe636900-1d02-11eb-8f78-0536103e25aa.png)
### cherry cola
**tags:** #theme #dark
**description:** a delightfully plummy, cherry cola flavored theme.
**author:** [runargs](https://github.com/runargs)
![](https://user-images.githubusercontent.com/16874139/97819898-9fe8bb80-1cff-11eb-846f-1a66e0302ebd.png)
### custom inserts
**tags:** #extension
**description:** link files for small client-side tweaks. (not sure how to do something? check out the
[tweaks](https://github.com/notion-enhancer/tweaks) collection.)
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | type |
| --------------------- | ---- |
| css insert | file |
| client-side js insert | file |
### dark+
**tags:** #theme #dark
**description:** a vivid-colour near-black theme.
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | type | values/defaults |
| -------------- | ----- | ------------------ |
| primary colour | color | `rgb(177, 24, 24)` |
![](https://user-images.githubusercontent.com/16874139/97820632-19ce7400-1d03-11eb-85a9-87f6d957dc96.png)
### dracula
**tags:** #theme #dark
**description:** a theme based on the popular dracula color palette originally by zeno rocha and friends.
**author:** [dracula](https://github.com/dracula/)
![](https://user-images.githubusercontent.com/16874139/97820175-04f0e100-1d01-11eb-9ede-b6e033a28cbc.png)
### emoji sets
**tags:** #extension
**description:** pick from a variety of emoji styles to use.
**author:** [dragonwocky](https://github.com/dragonwocky/)
| option | type | values/defaults |
| ------ | ------ | --------------------------------------------------------------------------------------------------------------- |
| style | select | twitter, apple, google, microsoft, samsung, whatsapp, facebook, joypixels, openmoji, emojidex, lg, htc, mozilla |
![](https://user-images.githubusercontent.com/16874139/97820652-3f5b7d80-1d03-11eb-80a6-34089b946711.png)
### focus mode
**tags:** #extension
**description:** hide the titlebar/menubar if the sidebar is closed (will be shown on hover).
**author:** [arecsu](https://github.com/arecsu/)
| option | extended description | type | values/defaults |
| --------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------ | --------------- |
| add padding to bottom of the page | 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. | toggle | on |
![](https://user-images.githubusercontent.com/16874139/97820337-da535800-1d01-11eb-9df5-55567cba2cc4.png)
### font chooser
**tags:** #extension
**description:** customize fonts. for each option, type in the name of
the font you would like to use, or leave it blank to not change anything.
**author:** [torchatlas](https://github.com/torchatlas)
| option | type |
| -------------------- | ---------- |
| sans-serif (inc. ui) | text input |
| serif | text input |
| monospace | text input |
| code | text input |
![](https://user-images.githubusercontent.com/16874139/97820678-61ed9680-1d03-11eb-8f9f-54c1c5faf25e.png)
### gameish
**tags:** #theme #dark
**description:** a purple, "gamer-styled" theme with a blocky-font.
**author:** [LVL100ShrekCultist](https://reddit.com/user/LVL100ShrekCultist/)
![](https://user-images.githubusercontent.com/16874139/97820696-75006680-1d03-11eb-8046-c3cb871ad34c.png)
### littlepig dark
**tags:** #theme #dark
**description:** a purple monospaced theme using emojis and colourful text.
**author:** [Lizishan](https://www.reddit.com/user/Lizishan/)
![](https://user-images.githubusercontent.com/16874139/97820718-919c9e80-1d03-11eb-9749-e04faef82e2d.png)
### littlepig light
**tags:** #theme #light
**description:** a bright monospaced theme using emojis and colourful text.
**author:** [Lizishan](https://www.reddit.com/user/Lizishan/)
![](https://user-images.githubusercontent.com/16874139/97820868-446cfc80-1d04-11eb-80ba-48cbedd62ed1.png)
### material ocean
**tags:** #theme #dark
**description:** an oceanic colour palette.
**author:** [blacksuan19](https://github.com/blacksuan19)
![](https://user-images.githubusercontent.com/16874139/97820253-6d3fc280-1d01-11eb-86d1-9932b364bad8.png)
### neutral
**tags:** #theme #dark
**description:** smoother colours and fonts, designed to be more pleasing to the eye.
**author:** [arecsu](https://github.com/arecsu/)
![](https://user-images.githubusercontent.com/16874139/97821029-fad0e180-1d04-11eb-9bad-2c76e9fa7613.png)
### night shift
**tags:** #extension #theme
**description:** sync dark/light theme with the system (overrides normal theme setting).
**author:** [dragonwocky](https://github.com/dragonwocky/)
### pastel dark
**tags:** #theme #dark
**description:** a true dark theme with a hint of pastel.
**author:** [zenith_illinois](https://reddit.com/user/zenith_illinois/)
![](https://user-images.githubusercontent.com/16874139/97820893-60709e00-1d04-11eb-8d52-55ab44000786.png)
### property layout
**tags:** #extension
**description:** auto-collapse page properties that usually push down page content.
**author:** [alexander-kazakov](https://github.com/alexander-kazakov/)
![](https://user-images.githubusercontent.com/16874139/97820916-81d18a00-1d04-11eb-8e07-b7519590157a.png)
### right-to-left
**tags:** #extension
**description:** enables auto rtl/ltr text direction detection.
**author:** [obahareth](https://github.com/obahareth/)
![](https://user-images.githubusercontent.com/16874139/97820953-a7f72a00-1d04-11eb-98c0-6ad83d097682.png)
### scroll to top
**tags:** #extension
**description:** add an arrow above the help button to scroll back to the top of a page.
**author:** [CloudHill](https://github.com/CloudHill/)
| option | type | values/defaults |
| --------------------------------------- | ------------ | --------------- |
| smooth scrolling | toggle | on |
| distance scrolled until button is shown | number input | 50 |
| unit to measure distance with | select | percent, pixels |
![](https://user-images.githubusercontent.com/16874139/97820445-4c2ba180-1d02-11eb-9d1a-911bca266f7f.png)
### weekly view
**tags:** #extension
**description:** calendar views named "weekly" will show only the 7 days of this week.
**author:** [adihd](https://github.com/adihd/)
![](https://user-images.githubusercontent.com/16874139/97820985-bf361780-1d04-11eb-9e2a-786a7c37477d.png)
### word counter
**tags:** #extension
**description:** add page details: word/character/sentence/block count & speaking/reading times.
**author:** [dragonwocky](https://github.com/dragonwocky/)
![](https://user-images.githubusercontent.com/16874139/97821003-d37a1480-1d04-11eb-8aaa-9e5dfea495eb.png)
## contributors
[@TarasokUA](https://github.com/TarasokUA/) wrote the first versions of this in python, in early 2020.
a couple months after I ([@dragonwocky](https://github.com/dragonwocky/)) picked the project up, at first extending
upon the original base and later moving to the javascript module system.
the enhancer wouldn't be anything near to what it is now though without
interested community members testing, coding and ideating features - some are listed as
[contributors](https://github.com/notion-enhancer/notion-enhancer/graphs/contributors) here on github,
but many more have been helping out on discord and in emails.
individual modules have their original authors attributed.
an enhancer/customiser for the all-in-one productivity workspace notion.so

View File

@ -1,55 +0,0 @@
# updating
the enhancer is still a young project, so it's growing quickly. this means a lot of stuff is changing internally
\- and, sometimes, externally.
previously (<= v0.7.0), the enhancer was a python script with a couple of resource files, and if you
wanted to customise things you had to go in and edit those files. in v0.8.0 there has been a complete
rewrite and overhaul: now this is a program that makes use of a number of modules and a graphical menu.
## installation dependencies
previously, python and the node.js `asar` package both had to be manually installed.
node.js is the only current requirement of the enhancer.
- python is no longer a dependency: keep it, get rid of it - up to you.
- the package installs asar itself in a more scoped environment: if you're confident with
the command line, you can remove the package with `npm remove -g asar`. otherwise, it
won't do any damage to just leave it.
## keeping the files
enhancement is done fully from the command prompt.
by default, there are no files for you to worry about.
you can delete the folder the old version of the enhancer is kept in.
(though you may want to keep the `user.css` file: see below.)
## user.css styling
when you first load the enhancer, there's no single file you can edit to see instant changes.
instead, the "custom inserts" module is used: you can use it to pick any javascript or css file anywhere
on your computer and include it every time you load up notion.
to make your own css file, make sure that your file manager has "show file extensions" ticked, then
create a text document and make sure the name ends in `.css` (e.g. `notion-tweaks.css`). or, just use
the old `user.css` from before the update.
most of the same css snippets will work, but some (e.g. preview page width) have been moved to the new variable
system, plus new ones have been found. it's a good idea to check what you have against the [tweaks](https://github.com/notion-enhancer/tweaks)
page and the [css theming documentation](DOCUMENTATION.md#variable-theming).
## configuration
"what happened to the tray options?"
"how can I set a custom window visibility toggle hotkey?"
these options and more have been moved to the graphical menu, which can be opened from the
tray or with `ALT+E` (while the notion app is focused).
## installing
just follow the normal [installation steps](README.md#installation) (starting from step 2, you should
already have node.js installed). don't worry about running `cleaner.py`, the new version will detect and overwrite
the old for you.

126
bin.js
View File

@ -1,126 +0,0 @@
#!/usr/bin/env node
'use strict';
import os from 'os';
import { line, cli, files, locations } from './pkg/helpers.js';
import check from './pkg/check.js';
import apply from './pkg/apply.js';
import remove from './pkg/remove.js';
const options = cli.options({
y: 'yes',
n: 'no',
d: 'dev',
h: 'help',
v: 'version',
}),
promptResponse = options.get('yes')
? 'y'
: options.get('no')
? 'n'
: undefined;
function displayHelp() {
const pkg = files.pkgJSON();
console.info(
cli.help({
name: pkg.name,
version: pkg.version,
link: pkg.homepage,
commands: [
['apply', 'add enhancements to the notion app'],
['remove', 'return notion to its pre-enhanced/pre-modded state'],
['check, status', 'check the current state of the notion app'],
],
options: [
['-y, --yes', 'skip prompts'],
['-n, --no', 'skip prompts'],
['-d, --dev', 'show detailed error messages (for debug purposes)'],
[
'--path=</path/to/notion/resources>',
'provide a file location to enhance (otherwise auto-picked)',
],
['-h, --help', 'display usage information'],
['-v, --version', 'display version number'],
],
})
);
process.exit(0);
}
if (options.get('help')) displayHelp();
function displayVersion() {
const pkg = files.pkgJSON();
console.info(
`${pkg.name}/${pkg.version} ${
process.platform
}-${os.arch()}/${os.release()} node/${process.version}`
);
process.exit(0);
}
if (options.get('version')) displayVersion();
function handleError(err) {
if (options.get('dev')) {
console.error(
err.stack
.split('\n')
.map((text, i) => {
text = text.replace(/^ /, ' ');
if (i > 1) return line.chalk.grey(text);
if (i > 0) return text;
const [type, msg] = text.split(/:((.+)|$)/);
return line.chalk.bold.red(`${type}:`) + msg;
})
.join('\n')
);
} else
console.error(
line.chalk`{bold.red ERROR:} ${err.message} {grey (run with -d for more information)}`
);
}
try {
switch (cli.args()[0]) {
case 'apply':
console.info(line.style.title('[NOTION-ENHANCER] APPLY'));
console.info(
(await apply({
overwriteOld: promptResponse,
__notion: options.get('path') || locations.notion(),
}))
? `${line.style.title('SUCCESS')} ${line.chalk.green('✔')}`
: `${line.style.title('CANCELLED')} ${line.chalk.red('✘')}`
);
break;
case 'remove':
console.info(line.style.title('[NOTION-ENHANCER] REMOVE'));
await remove({
deleteConfig: promptResponse,
deleteCache: promptResponse,
__notion: options.get('path') || locations.notion(),
});
console.info(`${line.style.title('SUCCESS')} ${line.chalk.green('✔')}`);
break;
case 'check':
case 'status':
console.info(line.style.title('[NOTION-ENHANCER] CHECK'));
const status = check({
__notion: options.get('path') || locations.notion(),
});
line.prev();
if (options.get('dev')) {
line.forward(24);
console.info(status);
} else {
line.forward(23);
line.write(': ' + status.msg + '\r\n');
}
break;
default:
displayHelp();
}
} catch (err) {
handleError(err);
}

142
bin.mjs Normal file
View File

@ -0,0 +1,142 @@
#!/usr/bin/env node
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
import os from 'os';
import { pkg, findNotion } from './pkg/helpers.mjs';
import { line, options, log, help, args, lastSpinner } from './pkg/cli.mjs';
import apply from './pkg/apply.mjs';
import remove from './pkg/remove.mjs';
import check from './pkg/check.mjs';
const manifest = pkg(),
opts = options({
y: 'yes',
n: 'no',
d: 'dev',
h: 'help',
v: 'version',
}),
promptRes = opts.get('yes') ? 'y' : opts.get('no') ? 'n' : undefined;
const displayHelp = () => {
help({
name: manifest.name,
version: manifest.version,
link: manifest.homepage,
commands: [
['apply', 'add enhancements to the notion app'],
['remove', 'return notion to its pre-enhanced/pre-modded state'],
['check, status', 'check the current state of the notion app'],
],
options: [
['-y, --yes', 'skip prompts'],
['-n, --no', 'skip prompts'],
['-d, --dev', 'show detailed error messages (for debug purposes)'],
[
'--path=</path/to/notion/resources>',
'provide a file location to enhance (otherwise auto-picked)',
],
['--no-backup', 'skip backup (faster enhancement, but disables removal)'],
['-h, --help', 'display usage information'],
['-v, --version', 'display version number'],
],
});
};
if (opts.get('help')) {
displayHelp();
process.exit(0);
}
if (opts.get('version')) {
log(
`${manifest.name}/${manifest.version} ${
process.platform
}-${os.arch()}/${os.release()} node/${process.version}`
);
process.exit(0);
}
function handleError(err) {
if (opts.get('dev')) {
const strs = [],
tags = [],
stack = err.stack.split('\n');
for (let i = 0; i < stack.length; i++) {
const text = stack[i].replace(/^ /, ' ');
if (i > 1) {
strs.push('{grey ');
tags.push(text);
strs.push('}');
tags.push('');
} else if (i > 0) {
strs.push('');
tags.push(text);
} else {
const [type, msg] = text.split(/:((.+)|$)/);
strs.push('{bold.red ');
tags.push(type);
strs.push(':} ');
tags.push(msg);
}
strs.push(i !== stack.length - 1 ? '\n' : '');
}
log(strs, ...tags);
} else {
log`{bold.red Error:} ${err.message} {grey (run with -d for more information)}`;
}
}
try {
const notionPath = opts.get('path') || findNotion();
switch (args()[0]) {
case 'apply': {
log`{bold.rgb(245,245,245) [NOTION-ENHANCER] APPLY}`;
const res = await apply(notionPath, {
overwritePrevious: promptRes,
takeBackup: opts.get('no-backup') ? false : true,
});
if (res) {
log`{bold.rgb(245,245,245) SUCCESS} {green ✔}`;
} else log`{bold.rgb(245,245,245) CANCELLED} {red ✘}`;
break;
}
case 'remove': {
log`{bold.rgb(245,245,245) [NOTION-ENHANCER] REMOVE}`;
const res = await remove(notionPath, { delCache: promptRes });
if (res) {
log`{bold.rgb(245,245,245) SUCCESS} {green ✔}`;
} else log`{bold.rgb(245,245,245) CANCELLED} {red ✘}`;
break;
}
case 'check':
case 'status': {
log`{bold.rgb(245,245,245) [NOTION-ENHANCER] CHECK}`;
const status = check(notionPath);
line.prev();
if (opts.get('dev')) {
line.forward(24);
console.log(status);
} else {
line.forward(23);
line.write(': ' + status.message + '\r\n');
}
break;
}
default:
displayHelp();
}
} catch (err) {
if (lastSpinner) lastSpinner.stop();
handleError(err);
process.exit(1);
}

View File

@ -1,105 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
module.exports = {
forced: true,
hidden: true,
id: '30a382b0-42e1-4a00-8c9d-7b2d9886a09a',
name: 'notion-enhancer core',
version: require('../package.json').version,
authors: [
{
name: 'dragonwocky',
link: 'https://dragonwocky.me/',
avatar: 'https://dragonwocky.me/avatar.jpg',
},
],
options: [
{
key: 'menu.autoresolve',
label: '**menu:** auto-resolve theme conflicts',
desc:
'enabling a theme will disable any other themes of the same mode (light/dark).',
type: 'toggle',
value: false,
},
{
key: 'openhidden',
label: 'hide app on open',
desc:
'app can be made visible by clicking the tray icon or using the hotkey.',
type: 'toggle',
value: false,
},
{
key: 'maximized',
label: 'auto-maximise windows',
desc:
'whenever a window is un-hidden or is created it will be maximised.',
type: 'toggle',
value: false,
},
{
key: 'close_to_tray',
label: 'close window to the tray',
desc: `pressing the × close button will hide the app instead of quitting it.\
it can be re-shown by clicking the tray icon or using the hotkey.`,
type: 'toggle',
value: true,
platformOverwrite: {
darwin: true,
},
},
{
key: 'hotkey',
label: '**hotkey:** toggle all windows',
desc: 'used to hide/show all app windows.',
type: 'input',
value: 'CommandOrControl+Shift+A',
},
{
key: 'menu_toggle',
label: '**hotkey:** toggle enhancements menu',
desc: 'used to open/close the menu while notion is focused.',
type: 'input',
value: 'Alt+E',
},
],
hacks: {
'renderer/preload.js': (
__exports,
store,
{ web: { whenReady, loadStyleset } }
) => {
whenReady(() => {
// document.defaultView.addEventListener('keyup', (event) => {
// // additional hotkeys
// if (event.key === 'F5') location.reload();
// // open menu on hotkey toggle
// if (store().get().menu_toggle) {
// const hotkey = {
// ctrlKey: false,
// metaKey: false,
// altKey: false,
// shiftKey: false,
// ...toKeyEvent(store().menu_toggle),
// };
// let triggered = true;
// for (let prop in hotkey)
// if (
// hotkey[prop] !== event[prop] &&
// !(prop === 'key' && event[prop] === 'Dead')
// )
// triggered = false;
// if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
// }
// });
});
},
},
};

View File

@ -1,158 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
const os = require('os'),
path = require('path'),
fs = require('fs-extra'),
store = require('./store.js'),
helperCache = {};
const enhancements = {};
enhancements.validate = (mod, others = []) => {
if (!mod.tags) mod.tags = [];
if (!mod.options) mod.options = [];
if (
[
typeof mod.id === 'string',
!others.find((m) => m.id === mod.id),
typeof mod.name === 'string',
mod.desc ? typeof mod.desc === 'string' : true,
typeof mod.version === 'string',
Array.isArray(mod.authors),
mod.authors.every(
(author) =>
typeof author === 'string' ||
(typeof author.name === 'string' &&
typeof author.link === 'string' &&
typeof author.avatar === 'string')
),
Array.isArray(mod.tags),
mod.tags.every((tag) => typeof tag === 'string'),
Array.isArray(mod.options),
mod.options.every((opt) =>
['toggle', 'select', 'input', 'file', 'color'].includes(opt.type)
),
].every((rule) => rule)
)
return true;
return false;
};
enhancements.defaults = (options) => {
const defaults = {};
for (let opt of options)
defaults[opt.key] = Object.keys(opt.platformOverwrite || {}).some(
(platform) => process.platform === platform
)
? opt.platformOverwrite[process.platform]
: Array.isArray(opt.value)
? opt.value[0]
: opt.value;
return defaults;
};
enhancements.list = () => {
if (helperCache.enhancements) return helperCache.enhancements;
const get = (repository) => {
if (!fs.existsSync(repository)) return [];
const modules = [];
for (let dir of fs
.readdirSync(repository)
.filter(
(dir) =>
!dir.startsWith('.') &&
fs.lstatSync(path.join(repository, dir)).isDirectory()
)) {
try {
const mod = require(path.resolve(`${repository}/${dir}/mod.js`));
if (!enhancements.validate(mod, modules)) throw Error;
mod.defaults = enhancements.defaults(mod.options);
modules.push({
...mod,
error: false,
source: path.resolve(`${repository}/${dir}`),
});
} catch (err) {
modules.push({ error: true, name: dir });
}
}
return modules.sort((a, b) => a.name.localeCompare(b.name));
};
const order = store('mods', '', { order: [] }).get('order'),
modCache = get(`${os.homedir()}/.notion-enhancer/cache`).map((m) => {
m.forced = false;
m.hidden = false;
return m;
});
helperCache.enhancements = {
core: get(__dirname),
cache: [
...modCache.filter((m) => !order.includes(m.id)),
...order.map((id) => modCache.find((m) => m.id === id)).filter((m) => m),
],
};
return helperCache.enhancements;
};
enhancements.get = (id) => {
const all = [...enhancements.list().core, ...enhancements.list().cache];
return all.find((m) => m.id === id);
};
enhancements.styles = (id) => {
if (!helperCache.styles) helperCache.styles = {};
if (helperCache.styles[id]) return helperCache.styles[id];
const mod = enhancements.get(id);
helperCache.styles[id] = {};
if (mod && !mod.error)
for (let sheet of ['global', 'app', 'tabs', 'menu'])
if (fs.pathExistsSync(path.resolve(`${mod.source}/${sheet}.css`)))
helperCache.styles[id][sheet] = `${mod.source}/${sheet}.css`;
return helperCache.styles[id];
};
enhancements.enabled = (id) => {
const mod = enhancements.get(id);
if (!mod || mod.error) return false;
return mod.forced || store('mods', 'enabled', { [id]: false }).get(id);
};
const web = {};
web.whenReady = (func = () => {}) => {
return new Promise((res, rej) => {
if (document.readyState !== 'complete') {
document.addEventListener('readystatechange', (event) => {
if (document.readyState === 'complete') {
func();
res(true);
}
});
} else {
func();
res(true);
}
});
};
web.createElement = (html) => {
const template = document.createElement('template');
template.innerHTML = html.trim();
return template.content.firstElementChild;
};
web.loadStyleset = (sheet) => {
for (let mod of [
...enhancements.list().core,
...enhancements.list().cache.reverse(),
])
if (enhancements.enabled(mod.id))
if (enhancements.styles(mod.id)[sheet])
document.head.appendChild(
web.createElement(
`<link rel="stylesheet" href="notion://enhancer/${mod.id}/${sheet}.css">`
)
);
return true;
};
function notionRequire(path) {
return require(`../../${path}`);
}
module.exports = { enhancements, web, notionRequire };

11
insert/init.js Normal file
View File

@ -0,0 +1,11 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
module.exports = function (target, __exports) {
console.log(target);
};

View File

@ -1,23 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
const helpers = require('./helpers.js'),
store = require('./store.js');
module.exports = function (target, __exports) {
for (let mod of [
...helpers.enhancements.list().core,
...helpers.enhancements.list().cache.reverse(),
])
if (helpers.enhancements.enabled(mod.id) && mod.hacks && mod.hacks[target])
mod.hacks[target](
__exports,
(defaults = {}) => store('config', mod.id, defaults),
{ ...helpers, directStore: store }
);
};

View File

@ -41,3 +41,7 @@ module.exports = (file, namespace = '', defaults = {}) => {
},
};
};
function notionRequire(path) {
return require(`../../${path}`);
}

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@ -1,36 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
module.exports = {
forced: true,
hidden: true,
id: '0f0bf8b6-eae6-4273-b307-8fc43f2ee082',
name: 'theming',
tags: ['core', 'theme'],
desc: 'loads & applies the theming variables and other css inserts.',
version: require('../package.json').version,
authors: [
{
name: 'dragonwocky',
link: 'https://dragonwocky.me/',
avatar: 'https://dragonwocky.me/avatar.jpg',
},
],
hacks: {
'renderer/preload.js': (
__exports,
store,
{ web: { whenReady, loadStyleset } }
) => {
whenReady(() => {
loadStyleset('global');
loadStyleset('app');
});
},
},
};

Binary file not shown.

Before

Width:  |  Height:  |  Size: 229 KiB

View File

@ -1,42 +1,46 @@
{
"name": "notion-enhancer",
"version": "0.11.0-wip",
"version": "0.11.0-dev",
"author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)",
"description": "an enhancer/customiser for the all-in-one productivity workspace notion.so",
"homepage": "https://github.com/notion-enhancer/notion-enhancer",
"license": "MIT",
"bin": {
"notion-enhancer": "bin.js"
"notion-enhancer": "bin.mjs"
},
"type": "module",
"engines": {
"node": ">=12.20.0"
"node": ">=16.x.x"
},
"scripts": {
"test": "echo \"no test specified\"",
"postinstall": "node bin.js apply -y",
"preuninstall": "node bin.js remove -n"
},
"dependencies": {
"asar": "^3.0.3",
"chalk": "^4.1.0"
"asar": "^3.1.0",
"chalk": "^4.1.2"
},
"repository": {
"type": "git",
"url": "git+https://github.com/notion-enhancer/notion-enhancer.git"
"url": "git+https://github.com/notion-enhancer/desktop.git"
},
"keywords": [
"notion",
"productivity",
"mod",
"loader",
"enhancer",
"hack",
"macOS",
"windows",
"linux"
"macos",
"linux",
"productivity",
"hack",
"extensions",
"themes",
"integrations",
"mod",
"mods",
"mod-loader",
"enhancer",
"notion",
"notion-enhancer"
],
"author": "dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)",
"license": "MIT",
"bugs": {
"url": "https://github.com/notion-enhancer/notion-enhancer/issues"
},
"homepage": "https://github.com/notion-enhancer/notion-enhancer"
"url": "https://github.com/notion-enhancer/desktop/issues"
}
}

View File

@ -1,133 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
import fs from 'fs';
import fsp from 'fs/promises';
import path from 'path';
import asar from 'asar';
import check from './check.js';
import remove from './remove.js';
import { locations, line, files } from './helpers.js';
export default async function ({
overwriteOld,
__notion = locations.notion(),
} = {}) {
let status = check({ __notion }),
spinner;
switch (status.code) {
case 1:
throw Error(status.msg);
case 2:
console.info(
line.chalk` {grey * notion-enhancer v${status.version} already applied}`
);
return true;
case 3:
console.warn(` * ${status.msg}`);
const prompt = {
prefix: line.chalk` {inverse > overwrite? [Y/n]:} `,
responses: ['Y', 'y', 'N', 'n', ''],
},
action = prompt.responses.includes(overwriteOld)
? overwriteOld
: (await line.read(prompt.prefix, prompt.responses)).toLowerCase();
if (action.toLowerCase() === 'n') {
console.info(' * keeping previous version: exiting');
return false;
}
await remove({ deleteConfig: 'n', deleteCache: 'n' });
status = check();
}
if (status.executable.endsWith('app.asar')) {
spinner = line.spinner(' * unpacking app files').loop();
asar.extractAll(
status.executable,
status.executable.replace(/\.asar$/, '')
);
spinner.stop();
spinner = line.spinner(' * backing up default app').loop();
await fsp.rename(status.executable, status.executable + '.bak');
status.executable = status.executable.replace(/\.asar$/, '');
spinner.stop();
} else {
spinner = line.spinner(' * backing up default app').loop();
await files.copyDir(status.executable, status.executable + '.bak');
spinner.stop();
}
if (
status.packed &&
[
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
'/opt/notion', // https://github.com/jaredallard/notion-app
].includes(__notion)
) {
spinner = line
.spinner(
line.chalk` * patching app launcher {grey (notion-app linux wrappers only)}`
)
.loop();
for (let bin of [
`/usr/bin/${__notion.split('/')[2]}`,
`${__notion}/${__notion.split('/')[2]}`,
]) {
const script = await fsp.readFile(bin, 'utf8');
if (script.includes('app.asar')) {
await fsp.writeFile(
bin,
script.replace(/(electron\d*) app(.asar)+/g, '$1 app')
);
}
}
spinner.stop();
}
// todo: patch app properties so dark/light mode can be detected
// process.platform === 'darwin' && path.resolve(`${status.executable}/../../Info.plist`)
spinner = line
.spinner(' * inserting enhancements + recording version')
.loop();
for (let file of (await files.readDirDeep(status.executable))
.map((file) => file.path)
.filter((file) => file.endsWith('.js') && !file.includes('node_modules'))) {
const target = file.slice(status.executable.length + 1);
let replacer = path.resolve(
`${files.__dirname(import.meta)}/replacers/${target}`
);
if (fs.existsSync(replacer)) {
replacer = (await import(replacer)).default;
await replacer(file);
}
await fsp.appendFile(
file,
`\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports);`
);
}
const node_modules = path.resolve(
`${status.executable}/node_modules/notion-enhancer`
);
await files.copyDir(
`${files.__dirname(import.meta)}/../insert`,
node_modules
);
await fsp.writeFile(
path.resolve(`${node_modules}/package.json`),
`{
"name": "notion-enhancer",
"version": "${files.pkgJSON().version}",
"main": "loader.js"
}`
);
spinner.stop();
return true;
}

93
pkg/apply.mjs Normal file
View File

@ -0,0 +1,93 @@
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
import fs from 'fs';
import fsp from 'fs/promises';
import path from 'path';
import asar from 'asar';
import { log, line, spinner } from './cli.mjs';
import { __dirname, pkg, findNotion, copyDir, readDirDeep } from './helpers.mjs';
import check from './check.mjs';
import remove from './remove.mjs';
export default async function (
notionFolder = findNotion(),
{ overwritePrevious = undefined, takeBackup = true } = {}
) {
let status = check(notionFolder);
switch (status.code) {
case 0: // not applied
break;
case 1: // corrupted
throw Error(status.message);
case 2: // same version already applied
log` {grey * notion-enhancer v${status.version} already applied}`;
return true;
case 3: // diff version already applied
log` * ${status.message}`;
const prompt = ['Y', 'y', 'N', 'n', ''],
res = prompt.includes(overwritePrevious)
? overwritePrevious
: await line.read(' {inverse > overwrite? [Y/n]:} ', prompt);
if (res.toLowerCase() === 'n') {
log` * keeping previous version: exiting`;
return false;
}
await remove(notionFolder, { cache: 'n' });
status = await check(notionFolder);
}
let s;
if (status.executable.endsWith('.asar')) {
s = spinner(' * unpacking app files').loop();
asar.extractAll(status.executable, status.executable.replace(/\.asar$/, ''));
s.stop();
}
if (takeBackup) {
s = spinner(' * backing up default app').loop();
if (status.executable.endsWith('.asar')) {
await fsp.rename(status.executable, status.executable + '.bak');
status.executable = status.executable.replace(/\.asar$/, '');
} else {
await copyDir(status.executable, status.executable + '.bak');
}
s.stop();
}
s = spinner(' * inserting enhancements').loop();
const notionFiles = (await readDirDeep(status.executable))
.map((file) => file.path)
.filter((file) => file.endsWith('.js') && !file.includes('node_modules'));
for (const file of notionFiles) {
const target = file.slice(status.executable.length + 1, -3),
replacer = path.resolve(`${__dirname(import.meta)}/replacers/${target}.mjs`);
if (fs.existsSync(replacer)) {
await (await import(`./replacers/${target}.mjs`)).default(file);
}
await fsp.appendFile(
file,
`\n\n//notion-enhancer\nrequire('notion-enhancer')('${target}', exports);`
);
}
s.stop();
s = spinner(' * recording version').loop();
const node_modules = path.resolve(`${status.executable}/node_modules/notion-enhancer`);
await copyDir(`${__dirname(import.meta)}/../insert`, node_modules);
await fsp.writeFile(
path.resolve(`${node_modules}/package.json`),
`{
"name": "notion-enhancer",
"version": "${pkg().version}",
"main": "launcher.js"
}`
);
s.stop();
return true;
}

View File

@ -1,75 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
import path from 'path';
import fs from 'fs';
import { locations, files } from './helpers.js';
export default function ({ __notion = locations.notion() }) {
const resolvePath = (filepath) => path.resolve(`${__notion}/${filepath}`),
pathExists = (filepath) => fs.existsSync(resolvePath(filepath)),
enhancerVersion = files.pkgJSON().version;
let notion = {
packed: pathExists('app.asar.bak'),
};
notion.backup = notion.packed
? pathExists('app.asar.bak')
? 'app.asar.bak'
: undefined
: pathExists('app.bak')
? 'app.bak'
: undefined;
if (!pathExists('app/node_modules/notion-enhancer')) {
notion.executable = pathExists('app')
? 'app'
: pathExists('app.asar')
? 'app.asar'
: undefined;
if (!notion.executable && notion.backup) {
notion.restored = true;
notion.backup = resolvePath(notion.backup);
notion.executable = notion.backup.replace(/\.bak$/, '');
fs.renameSync(notion.backup, notion.executable);
} else {
notion.executable = notion.executable
? resolvePath(notion.executable)
: '';
}
return notion.executable
? {
code: 0,
msg: `notion-enhancer has not been applied.`,
executable: notion.executable,
restored: notion.restored || false,
}
: {
code: 1,
msg: `notion installation has been corrupted: no executable found.`,
restored: notion.restored || false,
};
}
notion = {
version: files.readJSON(
resolvePath('app/node_modules/notion-enhancer/package.json')
).version,
executable: resolvePath('app'),
packed: resolvePath(notion.packed),
backup: resolvePath(notion.backup),
};
return notion.version === enhancerVersion
? {
code: 2,
msg: `notion-enhancer v${enhancerVersion} applied.`,
...notion,
}
: {
code: 3,
msg: `notion-enhancer v${notion.version} found applied != v${enhancerVersion} package.`,
...notion,
};
}

54
pkg/check.mjs Normal file
View File

@ -0,0 +1,54 @@
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
import fs from 'fs';
import path from 'path';
import { pkg, findNotion, findEnhancerCache } from './helpers.mjs';
export default function (notionFolder = findNotion()) {
const resolvePath = (filepath) => path.resolve(`${notionFolder}/${filepath}`),
pathExists = (filepath) => fs.existsSync(resolvePath(filepath)),
enhancerVersion = pkg().version;
const executableApp = pathExists('app'),
executableAsar = pathExists('app.asar'),
executable = executableApp ? 'app' : executableAsar ? 'app.asar' : undefined,
backupApp = pathExists('app.bak'),
backupAsar = pathExists('app.asar.bak'),
backup = backupApp ? 'app.bak' : backupAsar ? 'app.asar.bak' : undefined,
insert = pathExists('app/node_modules/notion-enhancer'),
insertVersion = insert
? pkg(resolvePath('app/node_modules/notion-enhancer/package.json')).version
: undefined,
insertCache = findEnhancerCache();
const res = {
executable: executable ? resolvePath(executable) : undefined,
backup: backup ? resolvePath(backup) : undefined,
cache: fs.existsSync(insertCache) ? insertCache : undefined,
};
if (insert) {
if (insertVersion === enhancerVersion) {
res.code = 2;
res.version = enhancerVersion;
res.message = `notion-enhancer v${enhancerVersion} applied.`;
} else {
res.code = 3;
res.version = insertVersion;
res.message = `notion-enhancer v${insertVersion} found applied != v${enhancerVersion} package.`;
}
} else {
if (executable) {
res.code = 0;
res.message = 'notion-enhancer has not been applied.';
} else {
res.code = 1;
res.message = 'notion installation has been corrupted, no executable found.';
}
}
return res;
}

138
pkg/cli.mjs Normal file
View File

@ -0,0 +1,138 @@
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
'use strict';
import chalk from 'chalk';
export const log = (strs, ...tags) => {
if (!Array.isArray(strs)) strs = [strs];
if (!strs.raw) strs.raw = [...strs];
console.log(chalk(strs, ...tags));
};
export const cursor = {
hide: () => process.stdout.write('\x1b[?25l'),
show: () => process.stdout.write('\x1b[?25h'),
};
export const line = {
clear: () => process.stdout.write('\r\x1b[K'),
backspace: (n = 1) => process.stdout.write('\b'.repeat(n)),
write: (string) => process.stdout.write(string),
prev: (n = 1) => process.stdout.write(`\x1b[${n}A`),
next: (n = 1) => process.stdout.write(`\x1b[${n}B`),
forward: (n = 1) => process.stdout.write(`\x1b[${n}C`),
back: (n = 1) => process.stdout.write(`\x1b[${n}D`),
new: () => process.stdout.write('\n'),
async read(prompt = '', values = []) {
let input = '';
prompt = [prompt];
prompt.raw = [prompt[0]];
prompt = chalk(prompt);
this.new();
do {
this.prev();
this.clear();
this.write(prompt);
input = await new Promise((res, rej) => {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.once('data', (key) => {
process.stdin.pause();
res(key.slice(0, -1));
});
});
} while (values.length && !values.includes(input));
return input;
},
};
export let lastSpinner;
export const spinner = (
message,
frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
complete = '→'
) => {
if (lastSpinner?.interval) lastSpinner.stop();
const spinner = {
interval: undefined,
i: 0,
step() {
this.i = (this.i + 1) % frames.length;
line.backspace(3);
line.write(chalk` {bold.yellow ${frames[this.i]}} `);
cursor.hide();
return this;
},
loop(ms = 80) {
if (this.interval) clearInterval(this.interval);
this.interval = setInterval(() => this.step(), ms);
return this;
},
stop() {
if (this.interval) {
clearInterval(this.interval);
this.interval = undefined;
}
line.backspace(3);
line.write(chalk` {bold.yellow ${complete}}\n`);
cursor.show();
return this;
},
};
line.write(chalk`${message} {bold.yellow ${frames[spinner.i]}} `);
lastSpinner = spinner;
return spinner;
};
export const args = () => process.argv.slice(2).filter((arg) => !arg.startsWith('-'));
export const options = (aliases = {}) => {
return new Map(
process.argv
.slice(2)
.filter((arg) => arg.startsWith('-'))
.map((arg) => {
let opt,
val = true;
if (arg.startsWith('--')) {
if (arg.includes('=')) {
[opt, val] = arg.slice(2).split(/=((.+)|$)/);
} else opt = arg.slice(2);
} else {
opt = arg.slice(1);
}
if (parseInt(val).toString() === val) val = +val;
if (aliases[opt]) opt = aliases[opt];
return [opt, val];
})
);
};
export const help = ({
name = process.argv[1].split('/').reverse()[0],
usage = `${name} <command> [options]`,
version = '',
link = '',
commands = [],
options = [],
}) => {
if (version) version = ' v' + version;
const cmdPad = Math.max(...commands.map((cmd) => cmd[0].length)),
optPad = Math.max(...options.map((opt) => opt[0].length));
commands = commands.map((cmd) => ` ${cmd[0].padEnd(cmdPad)} : ${cmd[1]}`).join('\n');
options = options.map((opt) => ` ${opt[0].padEnd(optPad)} : ${opt[1]}`).join('\n');
log`{bold.rgb(245,245,245) ${name}${version}}`;
if (link) log`{grey ${link}}`;
log`\n{bold.rgb(245,245,245) USAGE}`;
log`{yellow $} ${usage}`;
log`\n{bold.rgb(245,245,245) COMMANDS}`;
log`${commands}`;
log`\n{bold.rgb(245,245,245) OPTIONS}`;
log`${options}`;
};

View File

@ -1,250 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
import os from 'os';
import fs from 'fs';
import fsp from 'fs/promises';
import path from 'path';
import chalk from 'chalk';
import { fileURLToPath } from 'url';
import { execSync } from 'child_process';
const platform =
process.platform === 'linux' &&
os.release().toLowerCase().includes('microsoft')
? 'wsl'
: process.platform,
locationCache = {};
export const locations = {
notion() {
if (locationCache.notion) return locationCache.notion;
switch (platform) {
case 'darwin':
locationCache.notion = '/Applications/Notion.app/Contents/Resources';
break;
case 'win32':
locationCache.notion =
process.env.LOCALAPPDATA + '\\Programs\\Notion\\resources';
break;
case 'wsl':
const [drive, ...windowsPath] = execSync(
'cmd.exe /c echo %localappdata%',
{
encoding: 'utf8',
stdio: 'pipe',
}
);
locationCache.notion = `/mnt/${drive.toLowerCase()}${windowsPath
.slice(1, -2)
.join('')
.replace(/\\/g, '/')}/Programs/Notion/resources`;
break;
case 'linux':
for (let folder of [
'/usr/lib/notion-desktop/resources', // https://github.com/davidbailey00/notion-deb-builder/
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
'/opt/notion', // https://github.com/jaredallard/notion-app
])
if (fs.existsSync(folder)) locationCache.notion = folder;
}
return locationCache.notion;
},
enhancer() {
if (locationCache.enhancer) return locationCache.enhancer;
let home = os.homedir();
if (platform === 'wsl') {
const [drive, ...windowsPath] = execSync(
'cmd.exe /c echo %systemdrive%%homepath%',
{
encoding: 'utf8',
stdio: 'pipe',
}
);
home = `/mnt/${drive.toLowerCase()}${windowsPath
.slice(1, -2)
.join('')
.replace(/\\/g, '/')}`;
}
locationCache.enhancer = path.resolve(`${home}/.notion-enhancer`);
return locationCache.enhancer;
},
config() {
return `${this.enhancer()}/config`;
},
cache() {
return `${this.enhancer()}/cache`;
},
};
export const line = {
chalk: chalk,
style: {
title: chalk.bold.rgb(245, 245, 245),
},
clear: () => process.stdout.write('\r\x1b[K'),
write: (string) => process.stdout.write(string),
prev: (n = 1) => process.stdout.write(`\x1b[${n}A`),
next: (n = 1) => process.stdout.write(`\x1b[${n}B`),
forward: (n = 1) => process.stdout.write(`\x1b[${n}C`),
back: (n = 1) => process.stdout.write(`\x1b[${n}D`),
new: () => process.stdout.write('\n'),
async read(prompt = '', values = []) {
let input = '';
this.write(prompt);
this.new();
do {
for (let i = 0; i < prompt.split('\n').length; i++) {
this.prev();
this.clear();
}
this.write(prompt);
input = await new Promise((res, rej) => {
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.once('data', (key) => {
process.stdin.pause();
res(key.slice(0, -1));
});
});
} while (values.length && !values.includes(input));
return input;
},
spinner(
message,
frames = ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
complete = '→'
) {
const spinner = {
message,
frames,
complete,
interval: undefined,
i: 0,
};
spinner.step = () => {
spinner.i = (spinner.i + 1) % spinner.frames.length;
this.clear();
this.write(
line.chalk`${spinner.message} {bold.yellow ${frames[spinner.i]}} `
);
return spinner;
};
spinner.loop = (ms = 80) => {
if (!spinner.interval) spinner.interval = setInterval(spinner.step, ms);
return spinner;
};
spinner.stop = () => {
if (spinner.interval) clearInterval(spinner.interval);
this.clear();
this.write(line.chalk`${spinner.message} {bold.yellow ${complete}}\r\n`);
return spinner;
};
spinner.step();
return spinner;
},
};
export const cli = {
args() {
return process.argv.slice(2).filter((arg) => !arg.startsWith('-'));
},
options(aliases = {}) {
return new Map(
process.argv
.slice(2)
.filter((arg) => arg.startsWith('-'))
.map((arg) => {
let opt,
val = true;
if (arg.startsWith('--')) {
if (arg.includes('=')) {
[opt, val] = arg.slice(2).split(/=((.+)|$)/);
} else opt = arg.slice(2);
} else {
opt = arg.slice(1);
}
if (parseInt(val).toString() === val) val = +val;
if (aliases[opt]) opt = aliases[opt];
return [opt, val];
})
);
},
help({
name = process.argv[1].split('/').reverse()[0],
usage = `${name} <command> [options]`,
version = '',
link = '',
commands = [],
options = [],
}) {
if (version) version = ' v' + version;
if (link) link = '\n' + link;
const cmdPad = Math.max(...commands.map((cmd) => cmd[0].length));
commands = commands
.map((cmd) => ` ${cmd[0].padEnd(cmdPad)} : ${cmd[1]}`)
.join('\n');
const optPad = Math.max(...options.map((opt) => opt[0].length));
options = options
.map((opt) => ` ${opt[0].padEnd(optPad)} : ${opt[1]}`)
.join('\n');
return `${line.style.title(name)}${line.style.title(version)}${link}
\n${line.style.title('USAGE')}
${line.chalk.yellow('$')} ${usage}
\n${line.style.title('COMMANDS')}\n${commands}
\n${line.style.title('OPTIONS')}\n${options}`;
},
};
export const files = {
__dirname: (meta) => path.dirname(fileURLToPath(meta.url)),
readJSON(file, defaults = {}) {
try {
return {
...defaults,
...JSON.parse(fs.readFileSync(path.resolve(file))),
};
} catch {
return defaults;
}
},
pkgJSON() {
return this.readJSON(`${this.__dirname(import.meta)}/../package.json`);
},
async copyDir(src, dest) {
src = path.resolve(src);
dest = path.resolve(dest);
if (!fs.existsSync(dest)) await fsp.mkdir(dest);
for (let file of await fsp.readdir(src)) {
const stat = await fsp.lstat(path.join(src, file));
if (stat.isDirectory()) {
await this.copyDir(path.join(src, file), path.join(dest, file));
} else if (stat.isSymbolicLink()) {
await fsp.symlink(
await fsp.readlink(path.join(src, file)),
path.join(dest, file)
);
} else await fsp.copyFile(path.join(src, file), path.join(dest, file));
}
return true;
},
async readDirDeep(dir) {
dir = path.resolve(dir);
let files = [];
for (let file of await fsp.readdir(dir)) {
file = path.join(dir, file);
const stat = await fsp.lstat(file);
if (stat.isDirectory()) {
files = files.concat(await this.readDirDeep(file));
} else if (stat.isSymbolicLink()) {
files.push({ type: 'symbolic', path: file });
} else files.push({ type: 'file', path: file });
}
return files;
},
};

110
pkg/helpers.mjs Normal file
View File

@ -0,0 +1,110 @@
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
import os from 'os';
import fs from 'fs';
import fsp from 'fs/promises';
import path from 'path';
import { fileURLToPath } from 'url';
import { execSync } from 'child_process';
export const __dirname = (meta) => path.dirname(fileURLToPath(meta.url));
export const pkg = (filepath = `${__dirname(import.meta)}/../package.json`) => {
try {
return JSON.parse(fs.readFileSync(path.resolve(filepath)));
} catch {
return {};
}
};
export const platform =
process.platform === 'linux' && os.release().toLowerCase().includes('microsoft')
? 'wsl'
: process.platform;
let __notion;
export const findNotion = () => {
if (__notion) return __notion;
switch (platform) {
case 'darwin':
__notion = '';
const userInstall = `/Users/${process.env.USER}/Applications/Notion.app/Contents/Resources`,
globalInstall = '/Applications/Notion.app/Contents/Resources';
if (fs.existsSync(userInstall)) {
__notion = userInstall;
} else if (fs.existsSync(globalInstall)) {
__notion = globalInstall;
}
break;
case 'win32':
__notion = process.env.LOCALAPPDATA + '\\Programs\\Notion\\resources';
break;
case 'wsl':
const [drive, ...windowsPath] = execSync('cmd.exe /c echo %localappdata%', {
encoding: 'utf8',
stdio: 'pipe',
});
__notion = `/mnt/${drive.toLowerCase()}${windowsPath
.slice(1, -2)
.join('')
.replace(/\\/g, '/')}/Programs/Notion/resources`;
break;
case 'linux':
// https://aur.archlinux.org/packages/notion-app/
if (fs.existsSync('/opt/notion-app')) __notion = '/opt/notion-app';
}
return __notion;
};
let __enhancerCache;
export const findEnhancerCache = () => {
if (__enhancerCache) return __enhancerCache;
let home = os.homedir();
if (platform === 'wsl') {
const [drive, ...windowsPath] = execSync('cmd.exe /c echo %systemdrive%%homepath%', {
encoding: 'utf8',
stdio: 'pipe',
});
home = `/mnt/${drive.toLowerCase()}${windowsPath
.slice(1, -2)
.join('')
.replace(/\\/g, '/')}`;
}
__enhancerCache = path.resolve(`${home}/.notion-enhancer`);
return __enhancerCache;
};
export const copyDir = async (src, dest) => {
src = path.resolve(src);
dest = path.resolve(dest);
if (!fs.existsSync(dest)) await fsp.mkdir(dest);
for (let file of await fsp.readdir(src)) {
const stat = await fsp.lstat(path.join(src, file));
if (stat.isDirectory()) {
await copyDir(path.join(src, file), path.join(dest, file));
} else if (stat.isSymbolicLink()) {
await fsp.symlink(await fsp.readlink(path.join(src, file)), path.join(dest, file));
} else await fsp.copyFile(path.join(src, file), path.join(dest, file));
}
return true;
};
export const readDirDeep = async (dir) => {
dir = path.resolve(dir);
let files = [];
for (let file of await fsp.readdir(dir)) {
if (['node_modules', '.git'].includes(file)) continue;
file = path.join(dir, file);
const stat = await fsp.lstat(file);
if (stat.isDirectory()) {
files = files.concat(await readDirDeep(file));
} else if (stat.isSymbolicLink()) {
files.push({ type: 'symbolic', path: file });
} else files.push({ type: 'file', path: file });
}
return files;
};

View File

@ -1,107 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
import fs from 'fs';
import fsp from 'fs/promises';
import check from './check.js';
import { locations, line } from './helpers.js';
export default async function ({
deleteConfig,
deleteCache,
__notion = locations.notion(),
} = {}) {
const status = check({ __notion });
let spinner;
if (status.code > 1 && status.executable) {
spinner = line.spinner(' * removing enhancements').loop();
await fsp.rmdir(status.executable, { recursive: true });
spinner.stop();
} else console.warn(line.chalk.grey(' * enhancements not found: skipping'));
if (status.restored || status.backup) {
spinner = line.spinner(' * restoring backup').loop();
if (status.backup)
await fsp.rename(status.backup, status.backup.replace(/\.bak$/, ''));
spinner.stop();
} else console.warn(line.chalk.grey(' * backup not found: skipping'));
const prompt = {
prefix: line.chalk` {inverse > delete? [Y/n]:} `,
responses: ['Y', 'y', 'N', 'n', ''],
};
for (let folder of [
{
description: 'config folder',
name: 'config',
action: deleteConfig,
location: locations.config(),
},
{
description: 'module cache',
name: 'cache',
action: deleteCache,
location: locations.cache(),
},
]) {
if (fs.existsSync(folder.location)) {
console.info(` * ${folder.description} ${folder.location} found`);
const action = prompt.responses.includes(folder.action)
? folder.action
: (await line.read(prompt.prefix, prompt.responses)).toLowerCase();
if (action === folder.action)
console.info(
`${prompt.prefix}${folder.action} ${line.chalk.grey('(auto-filled)')}`
);
if (action !== 'n') {
spinner = line.spinner(` * deleting ${folder.name}`).loop();
await fsp.rmdir(folder.location, { recursive: true });
spinner.stop();
} else console.info(` * keeping ${folder.name}`);
} else
console.warn(
line.chalk.grey(` * ${folder.description} not found: skipping`)
);
}
if (
!fs.existsSync(locations.config()) &&
!fs.existsSync(locations.cache()) &&
fs.existsSync(locations.enhancer())
)
fsp.rmdir(locations.enhancer()).catch((err) => {});
if (
status.packed &&
[
'/opt/notion-app', // https://aur.archlinux.org/packages/notion-app/
'/opt/notion', // https://github.com/jaredallard/notion-app
].includes(__notion)
) {
spinner = line
.spinner(
line.chalk` * patching app launcher {grey (notion-app linux wrappers only)}`
)
.loop();
for (let bin of [
`/usr/bin/${__notion.split('/')[2]}`,
`${__notion}/${__notion.split('/')[2]}`,
]) {
const script = await fsp.readFile(bin, 'utf8');
if (!script.includes('app.asar')) {
await fsp.writeFile(
bin,
script.replace(/(electron\d*) app(.asar)+/g, '$1 app.asar')
);
}
}
spinner.stop();
}
return true;
}

46
pkg/remove.mjs Normal file
View File

@ -0,0 +1,46 @@
/*
* notion-enhancer
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license
*/
import fsp from 'fs/promises';
import { log, spinner, line } from './cli.mjs';
import { findNotion } from './helpers.mjs';
import check from './check.mjs';
export default async function (notionFolder = findNotion(), { delCache = undefined } = {}) {
const status = check(notionFolder);
let s;
if (status.code > 1 && status.executable) {
s = spinner(' * removing enhancements').loop();
await fsp.rm(status.executable, { recursive: true });
s.stop();
} else log` {grey * enhancements not found: skipping}`;
if (status.backup) {
s = spinner(' * restoring backup').loop();
await fsp.rename(status.backup, status.backup.replace(/\.bak$/, ''));
s.stop();
} else log` {grey * backup not found: skipping}`;
if (status.cache) {
log` * enhancer cache found: ${status.cache}`;
const prompt = ['Y', 'y', 'N', 'n', ''];
let res;
if (prompt.includes(delCache)) {
res = delCache;
log` {inverse > delete? [Y/n]:} ${delCache} {grey (auto-filled)}`;
} else res = await line.read(' {inverse > delete? [Y/n]:} ', prompt);
if (res.toLowerCase() === 'n') {
log` * keeping enhancer cache`;
} else {
s = spinner(' * deleting enhancer cache').loop();
await fsp.rm(status.cache, { recursive: true });
s.stop();
}
} else log` {grey * enhancer cache not found: skipping}`;
}

View File

@ -8,12 +8,12 @@
import fsp from 'fs/promises';
export default async function (file) {
export default async function (filepath) {
// https://github.com/notion-enhancer/notion-enhancer/issues/160
// enable the notion:// url scheme/protocol on linux
const contents = await fsp.readFile(file, 'utf8');
const contents = await fsp.readFile(filepath, 'utf8');
await fsp.writeFile(
file,
filepath,
contents.replace(
/process.platform === "win32"/g,
'process.platform === "win32" || process.platform === "linux"'

View File

@ -1,36 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://dragonwocky.me/notion-enhancer) under the MIT license
*/
'use strict';
import fsp from 'fs/promises';
export default async function (file) {
// https://github.com/notion-enhancer/notion-enhancer/issues/160
// enable the notion:// url scheme/protocol on linux
const contents = await fsp.readFile(file, 'utf8');
await fsp.writeFile(
file,
contents.replace(
/registerStreamProtocol\(config_1\.default\.protocol, async \(req, callback\) => {/,
`registerStreamProtocol(config_1.default.protocol, async (req, callback) => {
if (req.url.startsWith('notion://enhancer/')) {
const { enhancements } = require('notion-enhancer/helpers'),
query = req.url.replace(/^notion:\\/\\/enhancer\\//, '').split('/'),
mod = enhancements.get(query.shift());
if (mod && !mod.error) {
callback(
fs.createReadStream(
require('path').resolve(\`\${mod.source}/\${query.join('/')}\`)
)
);
return;
}
}`
)
);
return true;
}

View File

@ -1,9 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
@import './css/theme.css';
@import './css/scrollbars.css';
@import './css/titlebar.css';

View File

@ -1,106 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
module.exports = (store) => {
const helpers = require('../../pkg/helpers.js'),
path = require('path'),
fs = require('fs-extra'),
browser = require('electron').remote.getCurrentWindow(),
is_mac = process.platform === 'darwin',
buttons = {
element: helpers.createElement('<div class="window-buttons-area"></div>'),
insert: [
...((store('mods')['72886371-dada-49a7-9afc-9f275ecf29d3'] || {})
.enabled
? ['alwaysontop']
: []),
...(store().frameless && !store().tiling_mode && !is_mac
? ['minimize', 'maximize', 'close']
: []),
],
icons: {
raw: {
alwaysontop: {
on: fs.readFile(
path.resolve(`${__dirname}/icons/alwaysontop_on.svg`)
),
off: fs.readFile(
path.resolve(`${__dirname}/icons/alwaysontop_off.svg`)
),
},
minimize: fs.readFile(
path.resolve(`${__dirname}/icons/minimize.svg`)
),
maximize: {
on: fs.readFile(path.resolve(`${__dirname}/icons/maximize_on.svg`)),
off: fs.readFile(
path.resolve(`${__dirname}/icons/maximize_off.svg`)
),
},
close: fs.readFile(path.resolve(`${__dirname}/icons/close.svg`)),
},
alwaysontop() {
return browser.isAlwaysOnTop()
? buttons.icons.raw.alwaysontop.on
: buttons.icons.raw.alwaysontop.off; // '🠙' : '🠛'
},
minimize() {
return buttons.icons.raw.minimize; // '⚊'
},
maximize() {
return browser.isMaximized()
? buttons.icons.raw.maximize.on
: buttons.icons.raw.maximize.off; // '🗗' : '🗖'
},
close() {
return buttons.icons.raw.close; // '⨉'
},
},
actions: {
async alwaysontop() {
browser.setAlwaysOnTop(!browser.isAlwaysOnTop());
this.innerHTML = await buttons.icons.alwaysontop();
},
minimize() {
browser.minimize();
},
async maximize() {
browser.isMaximized() ? browser.unmaximize() : browser.maximize();
this.innerHTML = await buttons.icons.maximize();
},
close() {
browser.close();
},
},
};
if (!buttons.insert.includes('alwaysontop')) browser.setAlwaysOnTop(false);
(async () => {
for (let btn of buttons.insert) {
buttons.element.innerHTML += `<button class="window-button btn-${btn}">${await buttons.icons[
btn
]()}</button>`;
}
for (let btn of buttons.insert) {
buttons.element.querySelector(`.window-button.btn-${btn}`).onclick =
buttons.actions[btn];
}
if (store().frameless && !store().tiling_mode && !is_mac) {
window.addEventListener('resize', (event) => {
Promise.resolve(buttons.icons.maximize()).then((icon) => {
icon = icon.toString();
const el = buttons.element.querySelector('.btn-maximize');
if (el.innerHTML != icon) el.innerHTML = icon;
});
});
}
})();
return buttons;
};

View File

@ -1,269 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
'use strict';
module.exports = (store, __exports) => {
const electron = require('electron'),
helpers = require('../../pkg/helpers.js'),
notionIpc = require(`${helpers
.getNotionResources()
.replace(/\\/g, '/')}/app/helpers/notionIpc.js`),
{ toKeyEvent } = require('keyboardevent-from-electron-accelerator'),
tabsEnabled = (store('mods')['e1692c29-475e-437b-b7ff-3eee872e1a42'] || {})
.enabled;
document.defaultView.addEventListener('keyup', (event) => {
// additional hotkeys
if (event.key === 'F5') location.reload();
// open menu on hotkey toggle
if (store().menu_toggle) {
const hotkey = {
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
...toKeyEvent(store().menu_toggle),
};
let triggered = true;
for (let prop in hotkey)
if (
hotkey[prop] !== event[prop] &&
!(prop === 'key' && event[prop] === 'Dead')
)
triggered = false;
if (triggered) electron.ipcRenderer.send('enhancer:open-menu');
}
if (tabsEnabled) {
const tabStore = () => store('e1692c29-475e-437b-b7ff-3eee872e1a42');
if (tabStore().select_modifier) {
// switch between tabs via key modifier
const select_tab_modifier = {
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
...toKeyEvent(tabStore().select_modifier),
};
let triggered = true;
for (let prop in select_tab_modifier)
if (select_tab_modifier[prop] !== event[prop]) triggered = false;
if (
triggered &&
[
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'ArrowRight',
'ArrowLeft',
].includes(event.key)
)
electron.ipcRenderer.sendToHost('enhancer:select-tab', event.key);
}
if (tabStore().new_tab) {
// create/close tab keybindings
const new_tab_keybinding = {
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
...toKeyEvent(tabStore().new_tab),
};
let triggered = true;
for (let prop in new_tab_keybinding)
if (new_tab_keybinding[prop] !== event[prop]) triggered = false;
if (triggered) electron.ipcRenderer.sendToHost('enhancer:new-tab');
}
if (tabStore().close_tab) {
const close_tab_keybinding = {
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
...toKeyEvent(tabStore().close_tab),
};
let triggered = true;
for (let prop in close_tab_keybinding)
if (close_tab_keybinding[prop] !== event[prop]) triggered = false;
if (triggered) electron.ipcRenderer.sendToHost('enhancer:close-tab');
}
}
});
const attempt_interval = setInterval(enhance, 500);
async function enhance() {
if (
!document.querySelector('.notion-frame') ||
!document.querySelector('.notion-sidebar') ||
!document.querySelector('.notion-topbar')
)
return;
clearInterval(attempt_interval);
// frameless
if (store().frameless && !store().tiling_mode && !tabsEnabled) {
document.body.classList.add('frameless');
// draggable area
document
.querySelector('.notion-topbar')
.prepend(helpers.createElement('<div class="window-dragarea"></div>'));
}
// window buttons
if (!tabsEnabled) {
const buttons = require('./buttons.js')(store);
document
.querySelector('.notion-topbar > div[style*="display: flex"]')
.appendChild(buttons.element);
}
document
.querySelector('.notion-history-back-button')
.parentElement.nextElementSibling.classList.add(
'notion-topbar-breadcrumb'
);
document
.querySelector('.notion-topbar-share-menu')
.parentElement.classList.add('notion-topbar-actions');
const getStyle = (prop) =>
getComputedStyle(
document.querySelector('.notion-app-inner')
).getPropertyValue(prop);
// external theming
document.defaultView.addEventListener('keydown', (event) => {
if ((event.ctrlKey || event.metaKey) && event.key === 'f') {
notionIpc.sendNotionToIndex('search:set-theme', {
'mode': document.querySelector('.notion-dark-theme')
? 'dark'
: 'light',
'colors': {
'white': getStyle('--theme--option_active-color'),
'blue': getStyle('--theme--option_active-background'),
},
'borderRadius': 3,
'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'),
'shadowOpacity': 0.2,
});
}
});
function setAppTheme() {
const theme = document.querySelector('.notion-dark-theme')
? 'dark'
: 'light';
electron.ipcRenderer.send('enhancer:set-app-theme', theme);
}
setAppTheme();
new MutationObserver(setAppTheme).observe(
document.querySelector('.notion-app-inner'),
{ attributes: true }
);
electron.ipcRenderer.on('enhancer:get-app-theme', setAppTheme);
if (tabsEnabled) {
let tab_title = { img: '', emoji: '', text: '' };
if (process.platform === 'darwin')
document
.querySelector('.notion-sidebar [style*="37px"]:empty')
.remove();
const TITLE_OBSERVER = new MutationObserver(() =>
__electronApi.setWindowTitle('notion.so')
);
__electronApi.setWindowTitle = (title) => {
const $container =
document.querySelector(
'.notion-peek-renderer [style="padding-left: calc(126px + env(safe-area-inset-left)); padding-right: calc(126px + env(safe-area-inset-right)); max-width: 100%; width: 100%;"]'
) ||
document.querySelector(
'.notion-frame [style="padding-left: calc(96px + env(safe-area-inset-left)); padding-right: calc(96px + env(safe-area-inset-right)); max-width: 100%; margin-bottom: 8px; width: 100%;"]'
) ||
document.querySelector('.notion-peek-renderer') ||
document.querySelector('.notion-frame'),
icon = $container.querySelector(
'.notion-record-icon img:not([src^="data:"])'
),
img =
icon && icon.getAttribute('src')
? `<img src="${
icon.getAttribute('src').startsWith('/')
? 'notion://www.notion.so'
: ''
}${icon.getAttribute('src')}">`
: '',
emoji = icon ? icon.getAttribute('aria-label') : '';
let text = $container.querySelector('[placeholder="Untitled"]');
text = text
? text.innerText || 'Untitled'
: [
setTimeout(() => __electronApi.setWindowTitle(title), 250),
title,
][1];
TITLE_OBSERVER.disconnect();
TITLE_OBSERVER.observe($container, {
childList: true,
subtree: true,
characterData: true,
attributes: true,
});
if (
tab_title.img !== img ||
tab_title.emoji !== emoji ||
tab_title.text !== text
) {
tab_title = {
img,
emoji,
text,
};
electron.ipcRenderer.sendToHost('enhancer:set-tab-title', tab_title);
}
};
__electronApi.openInNewWindow = (urlPath) => {
electron.ipcRenderer.sendToHost(
'enhancer:new-tab',
`notion://www.notion.so${urlPath}`
);
};
} else if (store().frameless && !store().tiling_mode) {
let sidebar_width;
function setSidebarWidth(list) {
const new_sidebar_width =
list[0].target.style.height === 'auto'
? '0px'
: list[0].target.style.width;
if (new_sidebar_width !== sidebar_width) {
sidebar_width = new_sidebar_width;
electron.ipcRenderer.sendToHost(
'enhancer:sidebar-width',
sidebar_width
);
}
}
new MutationObserver(setSidebarWidth).observe(
document.querySelector('.notion-sidebar'),
{ attributes: true }
);
setSidebarWidth([{ target: document.querySelector('.notion-sidebar') }]);
}
}
};

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,89 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
'use strict';
module.exports = (store, __exports) => {
const electron = require('electron'),
allWindows = () =>
electron.BrowserWindow.getAllWindows().filter(
(win) => win.getTitle() !== 'notion-enhancer menu'
),
// createWindow = __exports.createWindow,
path = require('path'),
helpers = require('../../pkg/helpers.js');
__exports.createWindow = function (relativeUrl, focused_window) {
if (!relativeUrl) relativeUrl = '';
const window_state = require(`${helpers
.getNotionResources()
.replace(/\\/g, '/')}/app/node_modules/electron-window-state/index.js`)(
{
defaultWidth: 1320,
defaultHeight: 860,
}
),
rect = {
x: window_state.x,
y: window_state.y,
width: window_state.width,
height: window_state.height,
};
focused_window =
focused_window || electron.BrowserWindow.getFocusedWindow();
if (focused_window && !focused_window.isMaximized()) {
rect.x = focused_window.getPosition()[0] + 20;
rect.y = focused_window.getPosition()[1] + 20;
rect.width = focused_window.getSize()[0];
rect.height = focused_window.getSize()[1];
}
let window = new electron.BrowserWindow({
show: false,
backgroundColor: '#ffffff',
titleBarStyle: 'hiddenInset',
frame: !store().frameless,
webPreferences: {
preload: path.resolve(
`${helpers.getNotionResources()}/app/renderer/index.js`
),
webviewTag: true,
session: electron.session.fromPartition('persist:notion'),
enableRemoteModule: true,
},
...rect,
});
window.once('ready-to-show', function () {
if (
!store().openhidden ||
allWindows().some((win) => win.isVisible() && win.id != window.id)
) {
window.show();
window.focus();
if (store().maximized) window.maximize();
if (
(focused_window && focused_window.isFullScreen()) ||
window_state.isFullScreen
)
window.setFullScreen(true);
}
});
let intended_quit = false;
window.on('close', (e) => {
if (intended_quit || !store().close_to_tray || allWindows().length > 1) {
window_state.saveState(window);
window = null;
} else {
e.preventDefault();
window.hide();
}
});
electron.app.on('before-quit', () => (intended_quit = true));
window.loadURL(__exports.getIndexUrl(relativeUrl));
return window;
};
return __exports.createWindow;
};

View File

@ -1,43 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
.window-buttons-area {
display: flex;
align-items: center;
font-size: 14px;
}
.window-button {
background: transparent;
border: 0;
margin: 0px 0px 0px 9px;
width: 32px;
line-height: 26px;
border-radius: 4px;
font-size: 16px;
transition: background 0.2s;
cursor: default;
}
.window-button svg {
margin-top: 8px;
width: 14px;
height: 14px;
}
.window-button svg path {
fill: currentColor;
}
.window-button svg line {
stroke: currentColor;
}
.window-button:hover {
background: var(--theme--interactive_hover);
box-shadow: 0 0 0 0.5px var(--theme--interactive_hover-border);
}
.window-button.btn-close:hover {
background: var(--theme--button_close);
color: var(--theme--button_close-fill);
}

View File

@ -1,29 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
[data-tweaks*='[smooth_scrollbars]'] .notion-scroller {
cursor: auto;
}
[data-tweaks*='[smooth_scrollbars]'] ::-webkit-scrollbar {
width: 8px; /* vertical */
height: 8px; /* horizontal */
-webkit-app-region: no-drag;
}
[data-tweaks*='[smooth_scrollbars]'] ::-webkit-scrollbar-corner {
background-color: transparent; /* overlap */
}
[data-tweaks*='[smooth_scrollbars]'] ::-webkit-scrollbar-thumb {
border-radius: 5px;
}
[data-tweaks*='[smooth_scrollbars]'] ::-webkit-scrollbar-thumb {
background-color: var(--theme--scrollbar);
border: 1px solid var(--theme--scrollbar-border);
}
[data-tweaks*='[smooth_scrollbars]'] ::-webkit-scrollbar-thumb:hover {
background: var(--theme--scrollbar_hover);
}

File diff suppressed because it is too large Load Diff

View File

@ -1,48 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
@import './buttons.css';
.frameless .notion-topbar {
height: calc(var(--configured--dragarea_height, 15px) + 45px) !important;
}
.frameless .window-dragarea {
height: var(--configured--dragarea_height, 15px);
width: 100%;
}
.frameless .window-dragarea {
background: var(--theme--dragarea);
}
.frameless [style*='top: 10.4972px'] {
top: calc(10.4972px + var(--configured--dragarea_height, 15px)) !important;
}
@media (max-width: 760px) {
.frameless .notion-topbar {
height: calc(var(--configured--dragarea_height, 15px) + 80px) !important;
}
.frameless .notion-topbar > :nth-child(2) {
height: 80px !important;
display: grid !important;
grid-template-columns: 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr 1fr;
}
.window-buttons-area {
grid-row: 1;
grid-column: 9 / span end;
justify-content: flex-end;
}
.notion-topbar-breadcrumb {
grid-row: 2;
grid-column: 1 / span 8;
}
.notion-topbar-actions {
grid-row: 2;
grid-column: 9 / span end;
justify-content: flex-end;
}
}

View File

@ -1,762 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
const store = require('../../pkg/store.js'),
{ createElement, getEnhancements } = require('../../pkg/helpers.js'),
fs = require('fs-extra'),
path = require('path'),
electron = require('electron'),
{ toKeyEvent } = require('keyboardevent-from-electron-accelerator');
window['__start'] = async () => {
document.body.setAttribute('data-platform', process.platform);
// mod loader
const modules = getEnhancements();
if (modules.loaded.length) {
console.info(
`<notion-enhancer> enhancements loaded: ${modules.loaded
.map((mod) => mod.name)
.join(', ')}.`
);
}
if (modules.invalid.length) {
createAlert(
'error',
`invalid mods found: ${modules.invalid
.map((mod) => `<b>${mod}</b>`)
.join(', ')}.`
).append();
}
const coreStore = (...args) => {
const mod = modules.loaded.find(
(m) => m.id === '0f0bf8b6-eae6-4273-b307-8fc43f2ee082'
);
return !args.length
? store(mod.id, mod.defaults)
: args.length === 1 && typeof args[0] === 'object'
? store(mod.id, { ...mod.defaults, ...args[0] })
: store(args[0], { ...mod.defaults, ...args[1] });
};
electron.ipcRenderer.send('enhancer:get-app-theme');
electron.ipcRenderer.on('enhancer:set-app-theme', (event, theme) => {
document.body.className = `notion-${theme}-theme`;
});
const buttons = require('./buttons.js')(() => ({
'72886371-dada-49a7-9afc-9f275ecf29d3': {
enabled: (store('mods')['72886371-dada-49a7-9afc-9f275ecf29d3'] || {})
.enabled,
},
tiling_mode: coreStore().tiling_mode,
frameless: coreStore().frameless,
}));
document.querySelector('#titlebar').appendChild(buttons.element);
function createAlert(type, message) {
if (!type)
throw Error('<notion-enhancer> @ createAlert: no alert type specified');
const el = createElement(`
<section class="${type}" role="alert">
<p>${message}</p>
</section>
`);
return {
el,
resolve() {
el.remove();
},
prepend() {
document.querySelector('#alerts').prepend(el);
return this;
},
append() {
document.querySelector('#alerts').appendChild(el);
return this;
},
};
}
// update checker
fetch(
`https://api.github.com/repos/notion-enhancer/notion-enhancer/releases/latest`
)
.then((res) => res.json())
.then((res) => {
const raw_v = require('./mod.js').version,
version = {
local: raw_v.split(/[~-]/g)[0],
repo: res.tag_name.slice(1),
};
if (version.local == version.repo) return;
// compare func from https://github.com/substack/semver-compare
version.sorted = [version.local, version.repo].sort((a, b) => {
const pa = a.split('.'),
pb = b.split('.');
for (let i = 0; i < 3; i++) {
let na = Number(pa[i]),
nb = Number(pb[i]);
if (na > nb) return 1;
if (nb > na) return -1;
if (!isNaN(na) && isNaN(nb)) return 1;
if (isNaN(na) && !isNaN(nb)) return -1;
}
return 0;
});
createAlert(
'warning',
version.sorted[0] == version.local
? `update <b>v${version.repo}</b> available!<br>
run <code>npm i -g notion-enhancer</code>`
: `local build <b>v${raw_v}</b> is unstable.`
).prepend();
});
const $popup = document.querySelector('#popup');
document.addEventListener('keyup', (event) => {
if (event.key === 'F5') location.reload();
// further-configuration popup
if (
$popup.classList.contains('visible') &&
['Enter', 'Escape'].includes(event.key)
)
$popup.classList.remove('visible');
// close window on hotkey toggle
if (coreStore().menu_toggle) {
const hotkey = {
ctrlKey: false,
metaKey: false,
altKey: false,
shiftKey: false,
...toKeyEvent(coreStore().menu_toggle),
};
let triggered = true;
for (let prop in hotkey)
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
const meta =
!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;
if (
meta &&
document.activeElement.getAttribute('tabindex') === '0' &&
event.key === 'Enter'
)
document.activeElement.click();
if (document.activeElement.tagName.toLowerCase() === 'input') {
if (document.activeElement.type === 'checkbox' && event.key === 'Enter')
document.activeElement.checked = !document.activeElement.checked;
if (
['Escape', 'Enter'].includes(event.key) &&
document.activeElement.type !== 'checkbox' &&
(document.activeElement.parentElement.id !== 'search' ||
event.key === 'Escape')
)
document.activeElement.blur();
} else if (meta && event.key === '/')
document.querySelector('#search > input').focus();
if (
(event.ctrlKey || event.metaKey) &&
event.key === 'f' &&
!event.altKey &&
!event.shiftKey
)
document.querySelector('#search > input').focus();
});
let colorpicker_target = null;
const $colorpicker = colorjoe
.rgb('colorpicker')
.on('change', function (color) {
if (!colorpicker_target) return;
colorpicker_target.elem.style.setProperty(
'--configured--color-value',
color.css()
);
store(colorpicker_target.id)[colorpicker_target.key] = color.css();
})
.update();
document
.querySelector('#colorpicker')
.appendChild(createElement('<button class="close-modal"></button>'));
document.querySelectorAll('#popup .close-modal').forEach((el) =>
el.addEventListener('click', (event) => {
$popup.classList.remove('visible');
})
);
const conflicts = {
relaunch: null,
detected: () =>
store('mods', {
conflicts: { dark: false, light: false },
}).conflicts,
alerts: [],
check() {
document.body.classList.remove('conflict');
conflicts.alerts.forEach((alert) => alert.resolve());
conflicts.alerts = [];
const enabled = modules.loaded.filter(
(mod) =>
store('mods', { [mod.id]: { enabled: false } })[mod.id].enabled &&
mod.tags.includes('theme')
),
dark = enabled.filter((mod) => mod.tags.includes('dark')),
light = enabled.filter((mod) => mod.tags.includes('light'));
for (let mode of [
[dark, 'dark'],
[light, 'light'],
]) {
const conflictID = mode[0]
.map((mod) => mod.id)
.sort()
.join('||');
if (
conflicts.detected()[mode[1]] &&
conflicts.detected()[mode[1]][0] === conflictID &&
conflicts.detected()[mode[1]][1]
)
continue;
if (mode[0].length > 1) {
document.body.classList.add('conflict');
conflicts.detected()[mode[1]] = [conflictID, false];
const alert = createAlert(
'error',
`conflicting ${mode[1]} themes: ${mode[0]
.map((mod) => `<b>${mod.name}</b>`)
.join(
', '
)}. <br> resolve or <span data-action="dismiss" tabindex="0">dismiss</span> to continue.`
);
alert.el
.querySelector('[data-action="dismiss"]')
.addEventListener('click', (event) => {
conflicts.detected()[mode[1]] = [conflictID, true];
conflicts.check();
});
alert.append();
conflicts.alerts.push(alert);
} else conflicts.detected()[mode[1]] = false;
}
search();
},
};
function modified() {
conflicts.check();
if (conflicts.relaunch) return;
conflicts.relaunch = createAlert(
'info',
'changes may not fully apply until <span data-action="relaunch" tabindex="0">app relaunch</span>.'
);
conflicts.relaunch.el
.querySelector('[data-action="relaunch"]')
.addEventListener('click', (event) => {
electron.remote.app.relaunch();
electron.remote.app.quit();
});
conflicts.relaunch.append();
}
const search_filters = {
enabled: true,
disabled: true,
tags: new Set(
modules.loaded
.map((mod) => mod.tags)
.flat()
.sort()
),
};
function innerText(elem) {
let text = '';
for (let $node of elem.childNodes) {
if ($node.nodeType === 3) text += $node.textContent;
if ($node.nodeType === 1) {
if ($node.getAttribute('data-tooltip'))
text += $node.getAttribute('data-tooltip');
text += ['text', 'number'].includes($node.type)
? $node.value
: innerText($node);
}
}
return text;
}
function search() {
modules.loaded.forEach((mod) => {
const $search_input = document.querySelector('#search > input'),
conflictingIDs = [conflicts.detected().dark, conflicts.detected().light]
.filter((conflict) => conflict && !conflict[1])
.map(([mods, dismissed]) => mods.split('||'))
.flat();
if (
conflictingIDs.length ||
document.body.classList.contains('reorder')
) {
$search_input.disabled = true;
} else $search_input.disabled = false;
if (
!document.body.classList.contains('reorder') &&
(conflictingIDs.length
? !conflictingIDs.some((id) => id.includes(mod.id))
: (mod.elem.classList.contains('enabled') &&
!search_filters.enabled) ||
(mod.elem.classList.contains('disabled') &&
!search_filters.disabled) ||
!mod.tags.some((tag) => search_filters.tags.has(tag)) ||
($search_input.value &&
!innerText(mod.elem)
.toLowerCase()
.includes($search_input.value.toLowerCase().trim())))
)
return (mod.elem.style.display = 'none');
mod.elem.style.display = 'block';
});
}
document.querySelector('#search > input').addEventListener('input', search);
function createTag(tagname, onclick, color) {
if (!tagname)
throw Error('<notion-enhancer> @ createTag: no tagname specified');
if (!onclick)
throw Error('<notion-enhancer> @ createTag: no action specified');
const el = createElement(
`<span class="selected" ${
color ? `style="--tag_color: ${color}" ` : ''
}tabindex="0">${tagname}</span>`
);
document.querySelector('#tags').append(el);
el.addEventListener('click', (event) => {
if (
!document.body.classList.contains('reorder') &&
!document.body.classList.contains('conflict')
) {
el.className = el.className === 'selected' ? '' : 'selected';
onclick(el.className === 'selected');
}
});
return el;
}
createTag('enabled', (state) => [
((search_filters.enabled = state), search()),
]);
createTag('disabled', (state) => [
(search_filters.disabled = state),
search(),
]);
for (let tag of search_filters.tags)
createTag(`#${tag}`, (state) => [
state ? search_filters.tags.add(tag) : search_filters.tags.delete(tag),
search(),
]);
// mod info + options
function markdown(string) {
const parsed = string
.split('\n')
.map((line) =>
line
.trim()
.replace(/\s+/g, ' ')
// > quote
.replace(/^>\s+(.+)$/g, '<blockquote>$1</blockquote>')
// ~~strikethrough~~
.replace(/([^\\])?~~((?:(?!~~).)*[^\\])~~/g, '$1<s>$2</s>')
// __underline__
.replace(/([^\\])?__((?:(?!__).)*[^\\])__/g, '$1<u>$2</u>')
// **bold**
.replace(/([^\\])?\*\*((?:(?!\*\*).)*[^\\])\*\*/g, '$1<b>$2</b>')
// *italic*
.replace(/([^\\])?\*([^*]*[^\\*])\*/g, '$1<i>$2</i>')
// _italic_
.replace(/([^\\])?_([^_]*[^\\_])_/g, '$1<i>$2</i>')
// `code`
.replace(/([^\\])?`([^`]*[^\\`])`/g, '$1<code>$2</code>')
// ![image_title](source)
.replace(
/([^\\])?\!\[([^\]]*[^\\\]]?)\]\(([^)]*[^\\)])\)/g,
`$1<img alt="$2" src="$3" onerror="this.remove()">`
)
// [link](destination)
.replace(
/([^\\])?\[([^\]]*[^\\\]]?)\]\(([^)]*[^\\)])\)/g,
'$1<a href="$3">$2</a>'
)
)
.map((line) =>
line.startsWith('<blockquote>') ? line : `<p>${line}</p>`
)
.join('');
return parsed;
}
const file_icon = await fs.readFile(
path.resolve(`${__dirname}/icons/file.svg`)
),
question_icon = (
await fs.readFile(path.resolve(`${__dirname}/icons/question.svg`))
).toString();
function createOption(opt, id) {
let $opt;
const desc = opt.desc
? question_icon.replace(
'<svg',
`<svg data-tooltip="${opt.desc.replace(/"/g, '&quot;')}"`
)
: '';
switch (opt.type) {
case 'toggle':
$opt = `
<input type="checkbox" id="${opt.type}_${id}--${opt.key}"
${store(id, { [opt.key]: opt.value })[opt.key] ? 'checked' : ''}/>
<label for="${opt.type}_${id}--${opt.key}">
<span class="name">${opt.label}${desc}</span>
<span class="switch"></span>
</label>
`;
break;
case 'select':
$opt = `
<label for="${opt.type}_${id}--${opt.key}">${opt.label}${desc}</label>
<select id="${opt.type}_${id}--${opt.key}">
${opt.value
.map((val) => `<option value="${val}">${val}</option>`)
.join('')}
</select>
`;
break;
case 'input':
$opt = `
<label for="${opt.type}_${id}--${opt.key}">${opt.label}${desc}</label>
<input type="${typeof value === 'number' ? 'number' : 'text'}" id="${
opt.type
}_${id}--${opt.key}">
`;
break;
case 'color':
$opt = `
<label for="${opt.type}_${id}--${opt.key}">${opt.label}${desc}</label>
<input type="button" id="${opt.type}_${id}--${opt.key}">
`;
break;
case 'file':
$opt = `
<input type="file" id="${opt.type}_${id}--${opt.key}"
${
opt.extensions
? ` accept="${opt.extensions
.map((ext) => (ext.startsWith('.') ? ext : `.${ext}`))
.join(',')}"`
: ''
}>
<label for="${opt.type}_${id}--${opt.key}">
<span class="label">
<span class="name">${opt.label}${desc}</span>
<button class="clear"></button>
</span>
<span class="choose">
${file_icon}
<span class="path">${
store(id)[opt.key]
? store(id)[opt.key].split(path.sep).reverse()[0]
: 'choose a file...'
}</span>
</span>
</label>
`;
}
$opt = createElement(`<p class="${opt.type}">${$opt}</p>`);
if (opt.type === 'color') {
$opt
.querySelector(`#${opt.type}_${id}--${opt.key}`)
.style.setProperty(
'--configured--color-value',
store(id, { [opt.key]: opt.value })[opt.key]
);
} else if (opt.type === 'file') {
$opt.querySelector('.clear').addEventListener('click', (event) => {
store(id)[opt.key] = '';
$opt.querySelector('.path').innerText = 'choose a file...';
});
} else {
$opt.querySelector(`#${opt.type}_${id}--${opt.key}`).value = store(id, {
[opt.key]: opt.type === 'select' ? opt.value[0] : opt.value,
})[opt.key];
}
return $opt;
}
const $modules = document.querySelector('#modules'),
fileExists = (file) => fs.pathExistsSync(path.resolve(file));
for (let mod of modules.loaded) {
const enabled =
mod.alwaysActive ||
store('mods', {
[mod.id]: { enabled: false },
})[mod.id].enabled,
author =
typeof mod.author === 'object'
? mod.author
: {
name: mod.author,
link: `https://github.com/${mod.author}`,
avatar: `https://github.com/${mod.author}.png`,
};
if (enabled) {
for (let sheet of ['menu', 'variables']) {
if (fileExists(`${__dirname}/../${mod.dir}/${sheet}.css`)) {
document.head.appendChild(
createElement(
`<link rel="stylesheet" href="enhancement://${mod.dir}/${sheet}.css">`
)
);
}
}
}
mod.elem = createElement(`
<section class="${enabled ? 'enabled' : 'disabled'}${
mod.tags.includes('core') ? ' core' : ''
}" id="${mod.id}">
<div class="meta">
<h3 ${
mod.alwaysActive
? `>${mod.name}`
: `class="toggle">
<input type="checkbox" id="enable_${mod.id}"
${enabled ? 'checked' : ''} />
<label for="enable_${mod.id}">
<span class="name">${mod.name}</span>
<span class="switch"></span>
</label>`
}</h3>
<p class="tags">${mod.tags
.map((tag) => (tag.startsWith('#') ? tag : `#${tag}`))
.join(' ')}</p>
<div class="desc">${markdown(mod.desc)}</div>
<p>
<a href="${author.link}" class="author">
<img src="${author.avatar}" onerror="this.src='./icons/user.png'">
${author.name}
</a>
<span class="version">v${mod.version}</span>
</p>
</div>
${
mod.options && mod.options.length
? '<div class="options"></div>'
: ''
}
</section>
`);
const $enable = mod.elem.querySelector(`#enable_${mod.id}`);
if ($enable)
$enable.addEventListener('click', (event) => {
store('mods', { [mod.id]: { enabled: false } })[mod.id].enabled =
$enable.checked;
mod.elem.className = store('mods', { [mod.id]: { enabled: false } })[
mod.id
].enabled
? 'enabled'
: 'disabled';
if (
$enable.checked &&
coreStore().autoresolve &&
mod.tags.includes('theme')
) {
modules.loaded.forEach((other) => {
const $other_enable = other.elem.querySelector(
`#enable_${other.id}`
);
if (
other !== mod &&
$other_enable &&
$other_enable.checked &&
other.tags.includes('theme')
) {
for (let mode of ['dark', 'light'])
if (other.tags.includes(mode) && mod.tags.includes(mode))
$other_enable.click();
}
});
}
search();
modified();
});
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');
$opt.addEventListener('click', (event) => {
colorpicker_target = {
id: mod.id,
key: opt.key,
elem: $preview,
};
$colorpicker.set(store(mod.id)[opt.key]);
$popup.classList.add('visible');
});
} else {
$opt
.querySelector(`#${opt.type}_${mod.id}--${opt.key}`)
.addEventListener('change', (event) => {
modified();
if (opt.type === 'toggle') {
store(mod.id)[opt.key] = event.target.checked;
} else if (opt.type === 'file') {
if (event.target.files.length)
store(mod.id)[opt.key] = event.target.files[0].path;
$opt.querySelector('.path').innerText = store(mod.id)[opt.key]
? store(mod.id)[opt.key].split(path.sep).reverse()[0]
: 'choose a file...';
} else
store(mod.id)[opt.key] =
typeof opt.value === 'number'
? +event.target.value
: event.target.value;
});
}
$options.appendChild($opt);
}
if (mod.tags.includes('core')) $modules.append(mod.elem);
}
document
.querySelectorAll('input[type="checkbox"]')
.forEach((checkbox) =>
checkbox.addEventListener('click', (event) => event.target.blur())
);
conflicts.check();
// draggable re-ordering
const draggable = {
state: 0,
tags: ['b', 'span'],
$toggle: document.querySelector('#draggable-toggle'),
list: modules.loaded
.filter((m) => !m.tags.includes('core'))
.map((m) => m.elem),
target: null,
render() {
draggable.target = null;
for (let $node of draggable.list) {
$node.draggable = false;
$modules.append($node);
}
},
mouseover(event) {
if (!draggable.target && event.target.innerText) {
for (let $node of draggable.list) $node.draggable = false;
const $node = draggable.list.find(
(node) => node.innerText === event.target.innerText
);
if ($node) $node.draggable = draggable.state;
}
},
};
document.addEventListener('dragstart', (event) => {
draggable.target = event.target;
event.target.style.opacity = 0.5;
});
document.addEventListener('dragend', (event) => {
event.target.style.opacity = '';
});
document.addEventListener('dragover', (event) => {
event.preventDefault();
document
.querySelectorAll('.dragged-over')
.forEach((el) => el.classList.remove('dragged-over'));
const $node = [
draggable.list[0].previousElementSibling,
...draggable.list,
].find((node) => node.innerText === event.target.innerText);
if ($node) $node.classList.add('dragged-over');
});
document.addEventListener('drop', (event) => {
event.preventDefault();
document
.querySelectorAll('.dragged-over')
.forEach((el) => el.classList.remove('dragged-over'));
if (
draggable.target &&
draggable.target.innerText !== event.target.innerText
) {
const from = draggable.list.findIndex(
(node) => node.innerText === draggable.target.innerText
),
to =
event.target.innerText ===
draggable.list[0].previousElementSibling.innerText
? 0
: draggable.list.findIndex(
(node) => node.innerText === event.target.innerText
) + 1;
if (to >= 0) {
draggable.list.splice(
to > from ? to - 1 : to,
0,
draggable.list.splice(from, 1)[0]
);
store('mods').priority = draggable.list.map((m) => m.id);
}
}
draggable.render();
modified();
});
document.addEventListener('mouseover', draggable.mouseover);
draggable.render();
draggable.$toggle.addEventListener('click', (event) => {
draggable.state = !draggable.state;
draggable.tags = draggable.tags.reverse();
draggable.$toggle.innerHTML = `
<${draggable.tags[0]} data-bolded="configure">configure</${draggable.tags[0]}> |
<${draggable.tags[1]} data-bolded="reorder">reorder</${draggable.tags[1]}>
`;
document.body.classList[draggable.state ? 'add' : 'remove']('reorder');
$modules
.querySelectorAll('input')
.forEach((input) => (input.disabled = draggable.state));
search();
});
const $tooltip = document.querySelector('#tooltip');
document.querySelectorAll('[data-tooltip]').forEach((el) => {
el.addEventListener('mouseenter', (e) => {
$tooltip.innerText = el.getAttribute('data-tooltip');
$tooltip.classList.add('active');
});
el.addEventListener('mouseover', (e) => {
$tooltip.style.top = e.clientY - $tooltip.clientHeight + 'px';
$tooltip.style.left =
e.clientX < window.innerWidth / 2 ? e.clientX + 'px' : '';
$tooltip.style.right =
e.clientX > window.innerWidth / 2
? window.innerWidth - e.clientX + 'px'
: '';
});
el.addEventListener('mouseleave', (e) =>
$tooltip.classList.remove('active')
);
});
};

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="currentColor" viewBox="0 0 250 250"><path d="M124.859 234.52L67.5474 135.736H102.683V12.184H147.323V135.736H182.459L124.859 234.52Z" fill="currentColor"/></svg>

Before

Width:  |  Height:  |  Size: 231 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="currentColor" viewBox="0 0 250 250"><path d="M102.683 234.52V110.968H67.5474L124.859 12.184L182.459 110.968H147.323V234.52H102.683Z" fill="currentColor"/></svg>

Before

Width:  |  Height:  |  Size: 231 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="none" viewBox="0 0 250 250"><line x1="21.393" x2="233.525" y1="229.525" y2="17.393" stroke="#000" stroke-miterlimit="4.139" stroke-width="30"/><line x1="17.607" x2="229.739" y1="17.393" y2="229.525" stroke="#000" stroke-linejoin="round" stroke-width="30"/></svg>

Before

Width:  |  Height:  |  Size: 333 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 384 512"><path fill="currentColor" d="M224 136V0H24C10.7 0 0 10.7 0 24v464c0 13.3 10.7 24 24 24h336c13.3 0 24-10.7 24-24V160H248c-13.2 0-24-10.8-24-24zm160-14.1v6.1H256V0h6.1c6.4 0 12.5 2.5 17 7l97.9 98c4.5 4.5 7 10.6 7 16.9z"/></svg>

Before

Width:  |  Height:  |  Size: 287 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="currentColor" viewBox="0 0 250 250"><path d="M14.7346 227.26V7.03998H235.215V227.26H14.7346ZM46.4546 195.8H203.495V70.48H46.4546V195.8Z" fill="currentColor"/></svg>

Before

Width:  |  Height:  |  Size: 235 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="currentColor" viewBox="0 0 250 250"><path d="M16.1311 225.96V76.72H84.5111V8.07999H233.751V157.32H165.371V225.96H16.1311ZM110.771 53.58V76.72H165.371V131.32H207.491V53.58H110.771ZM42.3911 199.96H139.111V122.22H42.3911V199.96Z" fill="currentColor"/></svg>

Before

Width:  |  Height:  |  Size: 325 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="250" height="250" fill="currentColor" viewBox="0 0 250 250"><path d="M17.8021 138.04V106.072H232.074V138.04H17.8021Z" fill="currentColor"/></svg>

Before

Width:  |  Height:  |  Size: 192 B

View File

@ -1 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512"><path fill="currentColor" d="M256 8C119.043 8 8 119.083 8 256c0 136.997 111.043 248 248 248s248-111.003 248-248C504 119.083 392.957 8 256 8zm0 448c-110.532 0-200-89.431-200-200 0-110.495 89.472-200 200-200 110.491 0 200 89.471 200 200 0 110.53-89.431 200-200 200zm107.244-255.2c0 67.052-72.421 68.084-72.421 92.863V300c0 6.627-5.373 12-12 12h-45.647c-6.627 0-12-5.373-12-12v-8.659c0-35.745 27.1-50.034 47.579-61.516 17.561-9.845 28.324-16.541 28.324-29.579 0-17.246-21.999-28.693-39.784-28.693-23.189 0-33.894 10.977-48.942 29.969-4.057 5.12-11.46 6.071-16.666 2.124l-27.824-21.098c-5.107-3.872-6.251-11.066-2.644-16.363C184.846 131.491 214.94 112 261.794 112c49.071 0 101.45 38.304 101.45 88.8zM298 368c0 23.159-18.841 42-42 42s-42-18.841-42-42 18.841-42 42-42 42 18.841 42 42z"/></svg>

Before

Width:  |  Height:  |  Size: 849 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 324 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 279 KiB

View File

@ -1,655 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 admiraldus (https://github.com/admiraldus)
* under the MIT license
*/
@import './css/buttons.css';
@import './css/scrollbars.css';
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes fade {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
* {
box-sizing: border-box;
word-break: break-word;
text-decoration: none;
text-size-adjust: 100%;
font-family: var(--theme--font_sans);
outline-color: var(--theme--table-border);
}
html,
body {
width: 100%;
height: 100%;
margin: 0;
padding: 0;
display: block;
overflow: hidden;
background: var(--theme--main);
color: var(--theme--text);
}
main {
padding: 1em 1em 2.9em 1em;
height: 100%;
overflow: auto;
}
main section {
border-radius: 2px;
margin-bottom: 0.75em;
}
/* inline formatting */
code {
border-radius: 0.1em;
padding: 0.2em 0.4em;
font: 0.85em var(--theme--font_code);
background: var(--theme--code_inline-background);
}
button {
color: var(--theme--text);
}
u {
text-decoration: underline;
}
s {
text-decoration: line-through;
}
/* titlebar */
#titlebar::before {
content: '';
position: absolute;
width: 100%;
-webkit-app-region: no-drag;
top: 0;
left: 0;
height: 2px;
}
#titlebar {
display: flex;
-webkit-app-region: drag;
background: var(--theme--dragarea);
}
#titlebar button {
-webkit-app-region: no-drag;
}
#titlebar .window-buttons-area {
margin: 0.4em 0.4em 0.4em auto;
}
#titlebar .window-buttons-area:empty {
display: none;
}
[data-platform='darwin'] #titlebar {
height: 2.65em;
}
/* alerts */
#alerts [role='alert'] {
display: flex;
padding: 0.75em;
background: var(--theme--interactive_hover);
border: 1px solid var(--theme--interactive_hover-border);
}
#alerts [role='alert']::before {
content: '!';
display: block;
/* margin: auto 0; */
font-weight: bold;
font-size: 1.2em;
padding-right: 0.5rem;
color: var(--theme--interactive_hover-border);
}
#alerts [role='alert'] p {
font-size: 1rem;
margin: auto 0;
padding-left: 0.5em;
color: var(--theme--line_text);
}
#alerts .error::before {
color: var(--theme--select_red);
}
#alerts .error {
color: var(--theme--line_red-text);
background: var(--theme--line_red);
border-color: var(--theme--select_red);
}
#alerts .warning::before {
color: var(--theme--select_yellow);
}
#alerts .warning {
color: var(--theme--line_yellow-text);
background: var(--theme--line_yellow);
border-color: var(--theme--select_yellow);
}
#alerts .info::before {
color: var(--theme--select_blue);
}
#alerts .info {
color: var(--theme--line_blue-text);
background: var(--theme--line_blue);
border-color: var(--theme--select_blue);
}
#alerts .success::before {
content: '✓';
color: var(--theme--select_green);
}
#alerts .success {
color: var(--theme--line_green-text);
background: var(--theme--line_green);
border-color: var(--theme--select_green);
}
#alerts code {
background: transparent;
text-decoration: underline;
}
[data-action] {
text-decoration: underline dotted;
cursor: pointer;
}
/* search */
#search {
position: relative;
margin-bottom: 0.75em;
}
#search > svg {
position: absolute;
width: 1em;
height: 1em;
top: 1.3em;
left: 1em;
}
#search > svg path {
fill: var(--theme--text_ui_info);
}
#search > input {
width: 100%;
padding: 1em 1.4em 1em 2.8em;
font: 1em var(--theme--font_sans);
background: var(--theme--card);
border: 1px solid var(--theme--table-border);
color: var(--theme--text);
border-radius: 2px;
}
#search > input::placeholder {
font-weight: bold;
color: var(--theme--text_ui_info);
}
#search > input:focus {
box-shadow: var(--theme--table-border) 0.04em 0.04em,
var(--theme--table-border) -0.04em -0.04em,
var(--theme--table-border) -0.04em 0.04em,
var(--theme--table-border) 0.04em -0.04em;
outline: none;
}
#search #tags > span {
cursor: pointer;
display: inline-block;
font-size: 0.8em;
padding: 0.2em 0.5em;
margin-top: 0.5em;
background: var(--theme--option-background);
color: var(--theme--option-color);
border-radius: 2px;
transition: color 200ms, background 200ms, opacity 200ms;
user-select: none;
}
#search #tags > span:not(:last-child) {
margin-right: 0.5em;
}
#search #tags > span:hover {
background: var(--theme--option_hover-background);
color: var(--theme--option_hover-color);
}
#search #tags > span::before {
content: '× ';
}
#search #tags > .selected {
background: var(--tag_color, var(--theme--option_active-background));
color: var(--theme--option_active-color);
}
#search #tags > .selected::before {
content: '✓ ';
}
/* module meta */
#modules {
position: relative;
}
#modules section {
background: var(--theme--sidebar);
border: 1px solid var(--theme--table-border);
}
#modules section > div {
padding: 0.75em;
}
.notion-light-theme #modules section {
background: var(--theme--main);
}
#modules section h3,
#modules section p {
margin: 0;
font-size: 1rem;
}
#modules section .desc {
margin: 0.3em 0 0.4em 0;
font-size: 0.9em;
}
#modules section .desc p {
font-size: inherit;
margin: 0;
}
#modules section .desc blockquote {
margin: 0.3em 0;
border-left: 0.3em solid var(--theme--table-border);
padding-left: 0.7em;
}
#modules section .desc a {
color: currentColor;
text-decoration: underline dotted;
}
#modules section .desc img {
width: 100%;
max-width: 20em;
margin: 0.5em 0;
}
#modules section .desc :first-child img:first-child {
margin-top: 0;
}
#modules section .desc :last-child img:last-child {
margin-bottom: 0;
}
#modules section .author {
color: currentColor;
}
#modules section .author img {
height: 1em;
width: 1em;
margin-bottom: 0.15625em;
display: inline-block;
vertical-align: middle;
border-radius: 50%;
object-fit: cover;
}
#modules section .tags,
#modules section .version {
font-size: 0.85em;
color: var(--theme--text_ui);
}
/* module options */
#modules .disabled .options {
display: none;
}
#modules section .options {
border-top: 1px solid var(--theme--table-border);
background: var(--theme--card);
}
#modules section .options p {
font-size: 0.9em;
}
#modules section .options p:not(:last-child) {
padding-bottom: 0.5em;
border-bottom: 0.5px solid var(--theme--table-border);
margin-bottom: 0.5em;
}
svg[data-tooltip] {
height: 1em;
width: 1em;
margin: 0 0 -2px 1px;
color: var(--theme--text_ui_info);
}
#tooltip {
pointer-events: none;
position: absolute;
padding: 0.25em 0.5em 0.5em 0.5em;
margin: 0 1em;
border-radius: 3px;
box-shadow: var(--theme--box-shadow_strong);
border-right-width: 1px;
font-size: calc(var(--theme--font_label-size) * 0.8);
background: var(--theme--interactive_hover);
opacity: 0;
transition: opacity 120ms ease-in;
}
#tooltip.active {
opacity: 1;
}
.toggle *,
.input *,
.select *,
.color *,
.file * {
cursor: pointer;
}
.select select,
.input input[type='text'],
.input input[type='number'],
.file input[type='file'] + label .choose {
width: 100%;
margin: 0.25em 0;
font-size: 0.9rem;
padding: 0.4rem 0.2rem;
border: none;
color: var(--theme--text);
background: var(--theme--main);
}
.select select:focus,
.input input[type='text']:focus,
.input input[type='number']:focus,
.file input[type='file']:focus + label .choose,
.file input[type='file'] + label .choose:hover {
outline: var(--theme--table-border) solid 2px;
}
.file input[type='file'],
.toggle input[type='checkbox'] {
opacity: 0;
width: 0.1px;
height: 0.1px;
position: fixed;
}
.input input[type='text'],
.input input[type='number'] {
padding: 0.4rem;
cursor: text;
}
.file input[type='file'] + label .label {
position: relative;
display: flex;
}
.file input[type='file'] + label .label .name {
flex-basis: calc(100% - 1.5rem);
}
.file input[type='file'] + label .label .clear {
font-size: 1rem;
position: absolute;
top: 0.4em;
right: 0;
width: 1em;
height: 0.1em;
border: 0.35em solid var(--theme--card);
background: currentColor;
}
.file input[type='file'] + label .choose {
display: block;
white-space: nowrap;
overflow: hidden;
}
.file input[type='file'] + label .choose svg {
padding-top: 0.5em;
height: 1.25em;
width: 1.25em;
}
.toggle input[type='checkbox'] + label {
display: flex;
--menu--toggle_bg: rgba(135, 131, 120, 0.3);
}
.toggle input[type='checkbox'] + label .name {
flex-basis: calc(100% - 2.25em);
margin-right: 0.75em;
}
.toggle input[type='checkbox'] + label .switch {
position: relative;
top: 0.2em;
float: right;
height: 1em;
width: 1.85em;
padding: 0.1em;
background: var(--menu--toggle_bg);
border-radius: 3.14em;
transition: background 300ms;
}
.toggle input[type='checkbox'] + label .switch::before {
content: '';
display: block;
width: 0.8em;
height: 0.8em;
border-radius: 50%;
transform: translateX(var(--menu--toggle_offset, 0));
transition: transform 350ms, box-shadow 350ms;
background: var(--theme--option_active-color);
/* box-shadow: 2px 1px 4px var(--theme--table-border); */
}
.toggle input[type='checkbox']:checked + label {
--menu--toggle_offset: 0.8em;
--menu--toggle_bg: var(--theme--primary);
}
.color {
display: flex;
}
.color label {
flex-basis: 70%;
}
.color input[type='button'] {
flex-basis: 30%;
box-shadow: 2px 1px 4px var(--theme--table-border);
border: 1px solid var(--theme--option_active-color);
border-radius: 3px;
background: var(--configured--color-value);
margin: 0;
}
.color input[type='button']:focus {
box-shadow: 3px 2px 5px var(--theme--table-border);
}
/* further-configuration popup */
#popup,
#popup-overlay {
position: absolute;
top: 0;
height: 100vh;
width: 100vw;
}
#popup {
display: none;
}
#popup.visible {
display: flex;
animation: fade 200ms ease;
}
#popup-overlay {
background: var(--theme--overlay);
}
.colorPicker {
margin: auto;
position: relative;
border: 1px solid var(--theme--table-border);
background: var(--theme--card);
}
.colorPicker .twod {
border-radius: 4px;
}
.colorPicker .twod .bg {
border-radius: 2px;
}
.colorPicker .oned,
.colorPicker .oned .bg {
margin-left: 0;
height: 212.5px;
}
.colorPicker .oned .bg {
border-radius: 4px;
border: 1px solid var(--theme--table-border);
}
.colorPicker > button {
display: block;
position: absolute;
bottom: 8px;
right: 8px;
margin: 0;
padding: 0;
border: none;
width: 21px;
height: 20px;
cursor: pointer;
background: transparent;
transition: background 0.2s;
}
.colorPicker > button::after {
content: '×';
font-size: 1.5em;
position: relative;
bottom: 5px;
}
.colorPicker > button:hover {
background: var(--theme--interactive_hover);
border-radius: 4px;
box-shadow: 0 0 0 0.5px var(--theme--interactive_hover-border);
}
.colorPicker > button:focus {
outline: none;
box-shadow: 0 0 0 1px var(--theme--table-border);
}
.colorPicker .twod .pointer .shape.shape1 {
width: 11px;
height: 11px;
}
.colorPicker .twod .pointer .shape.shape2 {
width: 9px;
height: 9px;
}
.colorPicker .oned .pointer .shape {
height: 6.5px;
margin-left: 0;
border: 2px solid #fff;
box-shadow: 0 0 0 1px #000;
}
.shape {
cursor: pointer;
}
@media (max-width: 300px) {
.colorPicker .twod,
.colorPicker .twod .bg {
width: 200px;
height: 200px;
}
.colorPicker .oned,
.colorPicker .oned .bg {
height: 172.5px;
}
}
@media (max-width: 250px) {
.colorPicker .twod,
.colorPicker .twod .bg {
width: 150px;
height: 150px;
}
.colorPicker .oned,
.colorPicker .oned .bg {
height: 132.5px;
}
}
/* draggable re-ordering of mods */
#draggable-toggle {
background: none;
border: none;
margin-top: 0.8em;
padding-left: 0;
cursor: pointer;
color: var(--theme--text_ui);
}
[data-bolded] {
display: inline-flex;
flex-direction: column;
}
[data-bolded]::after {
content: attr(data-bolded);
height: 0;
visibility: hidden;
overflow: hidden;
user-select: none;
pointer-events: none;
font-weight: bold;
}
.reorder #search #tags > span,
.reorder #search #tags > span:hover,
.conflict #search #tags > span,
.conflict #search #tags > span:hover {
opacity: 0.7;
background: var(--theme--option-background);
}
.reorder #search #tags > .selected,
.reorder #search #tags > .selected:hover,
.conflict #search #tags > .selected,
.conflict #search #tags > .selected:hover {
background: var(--tag_color, var(--theme--option_active-background));
}
.reorder #modules .dragged-over::after {
content: '';
height: 0.25em;
width: 99%;
position: absolute;
margin: 0.3em 0;
opacity: 0.7;
background: var(--theme--selected);
}
.reorder #modules .switch,
.reorder #modules .tags,
.reorder #modules .desc,
.reorder #modules .options,
.reorder #modules .author,
.reorder #modules .version {
display: none;
}
.reorder #modules .core .toggle * {
cursor: text;
}
.reorder #modules section:not(.core) label::before {
content: '::';
margin-right: 0.4em;
color: var(--theme--text_ui);
}

View File

@ -1,43 +0,0 @@
<!DOCTYPE html>
<html data-tweaks="[smooth_scrollbars]" lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>notion-enhancer menu</title>
<script src="./colorjoe/min.js"></script>
<link rel="stylesheet" href="./colorjoe/picker.css" />
<style>
body {
display: none;
}
</style>
</head>
<body class="notion-dark-theme">
<header id="titlebar"></header>
<main>
<div id="alerts"></div>
<div id="search">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512">
<path
d="M505 442.7L405.3 343c-4.5-4.5-10.6-7-17-7H372c27.6-35.3 44-79.7 44-128C416 93.1 322.9 0 208 0S0 93.1 0 208s93.1 208 208 208c48.3 0 92.7-16.4 128-44v16.3c0 6.4 2.5 12.5 7 17l99.7 99.7c9.4 9.4 24.6 9.4 33.9 0l28.3-28.3c9.4-9.4 9.4-24.6.1-34zM208 336c-70.7 0-128-57.2-128-128 0-70.7 57.2-128 128-128 70.7 0 128 57.2 128 128 0 70.7-57.2 128-128 128z"
></path>
</svg>
<input type="text" placeholder="search ('/' to focus)" />
<div id="tags"></div>
<button id="draggable-toggle">
<b data-bolded="configure">configure</b> |
<span data-bolded="reorder">reorder</span>
</button>
</div>
<div id="modules"></div>
</main>
<section id="popup">
<div id="popup-overlay" class="close-modal"></div>
<div id="colorpicker"></div>
</section>
<span id="tooltip"></span>
<script>
window['__start']();
</script>
</body>
</html>

View File

@ -1,103 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
module.exports = {
id: '0f0bf8b6-eae6-4273-b307-8fc43f2ee082',
alwaysActive: true,
tags: ['core'],
name: 'notion-enhancer core',
desc: 'the cli, modloader, menu, & tray.',
version: require('../../package.json').version,
author: 'dragonwocky',
options: [
{
key: 'autoresolve',
label: 'auto-resolve theme conflicts',
desc:
'when a theme is enabled any other themes of the same mode (light/dark) will be disabled.',
type: 'toggle',
value: false,
},
{
key: 'openhidden',
label: 'hide app on open',
desc:
'app can be made visible by clicking the tray icon or using the hotkey.',
type: 'toggle',
value: false,
},
{
key: 'maximized',
label: 'auto-maximise windows',
desc:
'whenever a window is un-hidden or is created it will be maximised.',
type: 'toggle',
value: false,
},
{
key: 'close_to_tray',
label: 'close window to the tray',
desc: `pressing the × close button will hide the app instead of quitting it.\
it can be re-shown by clicking the tray icon or using the hotkey.`,
type: 'toggle',
value: true,
platformOverwrite: {
darwin: true,
},
},
{
key: 'frameless',
label: 'integrated titlebar',
desc: `replace the native titlebar with buttons inset into the app.`,
type: 'toggle',
value: true,
platformOverwrite: {
darwin: false,
},
},
{
key: 'tiling_mode',
label: 'tiling window manager mode',
desc: `completely remove the close/minimise/maximise buttons -
this is for a special type of window manager. if you don't understand it, don't use it.`,
type: 'toggle',
value: false,
},
{
key: 'hotkey',
label: 'window display hotkey:',
desc: 'used to toggle hiding/showing all app windows.',
type: 'input',
value: 'CommandOrControl+Shift+A',
},
{
key: 'menu_toggle',
label: 'open enhancements menu hotkey:',
desc: 'used to toggle opening/closing this menu while notion is focused.',
type: 'input',
value: 'Alt+E',
},
{
key: 'default_page',
label: 'default page id/url:',
desc: `every new tab/window that isn't opening a url via the notion://\
protocol will load this page. to get a page link from within the app,\
go to the triple-dot menu and click "copy link".\
leave blank to just load the last page you opened.`,
type: 'input',
value: '',
},
],
hacks: {
'main/main.js': require('./tray.js'),
'main/systemMenu.js': require('./systemMenu.js'),
'main/createWindow.js': require('./createWindow.js'),
'renderer/index.js': require('./render.js'),
'renderer/preload.js': require('./client.js'),
},
};

File diff suppressed because it is too large Load Diff

View File

@ -1,477 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
module.exports = (store, __exports) => {
const electron = require('electron'),
fs = require('fs-extra'),
{ getNotionResources } = require('../../pkg/helpers.js'),
__notion = getNotionResources(),
createWindow = require(`${__notion}/app/main/createWindow.js`),
config = require(`${__notion}/app/config.js`),
notion_intl = require(`${__notion}/app/shared/notion-intl/index.js`),
localizationHelper = require(`${__notion}/app/helpers/localizationHelper.js`),
isMac = process.platform === 'darwin',
// why is it inversed? i have no idea, but for some reason this is what works
tabsEnabled = !(store('mods')['e1692c29-475e-437b-b7ff-3eee872e1a42'] || {})
.enabled,
menuMessages = notion_intl.defineMessages({
fileMenuTitle: {
id: 'desktopTopbar.fileMenu.title',
defaultMessage: 'File',
},
editMenuTitle: {
id: 'desktopTopbar.editMenu.title',
defaultMessage: 'Edit',
},
viewMenuTitle: {
id: 'desktopTopbar.viewMenu.title',
defaultMessage: 'View',
},
windowMenuTitle: {
id: 'desktopTopbar.windowMenu.title',
defaultMessage: 'Window',
},
helpTitle: {
id: 'desktopTopbar.helpMenu.title',
defaultMessage: 'Help',
},
newWindow: {
id: 'desktopTopbar.fileMenu.newWindow',
defaultMessage: 'New Window',
},
closeWindow: {
id: 'desktopTopbar.fileMenu.close',
defaultMessage: 'Close Window',
},
quit: {
id: 'desktopTopbar.fileMenu.quit',
defaultMessage: 'Exit',
},
undo: {
id: 'desktopTopbar.editMenu.undo',
defaultMessage: 'Undo',
},
redo: {
id: 'desktopTopbar.editMenu.redo',
defaultMessage: 'Redo',
},
cut: {
id: 'desktopTopbar.editMenu.cut',
defaultMessage: 'Cut',
},
copy: {
id: 'desktopTopbar.editMenu.copy',
defaultMessage: 'Copy',
},
paste: {
id: 'desktopTopbar.editMenu.paste',
defaultMessage: 'Paste',
},
selectAll: {
id: 'desktopTopbar.editMenu.selectAll',
defaultMessage: 'Select All',
},
startSpeaking: {
id: 'desktopTopbar.editMenu.speech.startSpeaking',
defaultMessage: 'Start Speaking',
},
stopSpeaking: {
id: 'desktopTopbar.editMenu.speech.stopSpeaking',
defaultMessage: 'Stop Speaking',
},
speech: {
id: 'desktopTopbar.editMenu.speech',
defaultMessage: 'Speech',
},
reload: {
id: 'desktopTopbar.viewMenu.reload',
defaultMessage: 'Reload',
},
togglefullscreen: {
id: 'desktopTopbar.viewMenu.togglefullscreen',
defaultMessage: 'Toggle Full Screen',
},
toggleDevTools: {
id: 'desktopTopbar.toggleDevTools',
defaultMessage: 'Toggle Developer Tools',
},
toggleWindowDevTools: {
id: 'desktopTopbar.toggleWindowDevTools',
defaultMessage: 'Toggle Window Developer Tools',
},
maximize: {
id: 'desktopTopbar.windowMenu.maximize',
defaultMessage: 'Maximize',
},
minimize: {
id: 'desktopTopbar.windowMenu.minimize',
defaultMessage: 'Minimize',
},
zoom: {
id: 'desktopTopbar.windowMenu.zoom',
defaultMessage: 'Zoom',
},
front: {
id: 'desktopTopbar.windowMenu.front',
defaultMessage: 'Front',
},
close: {
id: 'desktopTopbar.windowMenu.close',
defaultMessage: 'Close',
},
help: {
id: 'desktopTopbar.helpMenu.openHelpAndSupport',
defaultMessage: 'Open Help & Support',
},
reset: {
id: 'desktopTopbar.appMenu.resetAppAndClearData',
defaultMessage: 'Reset App & Clear Local Data',
},
about: {
id: 'desktopTopbar.appMenu.about',
defaultMessage: 'About Notion',
},
services: {
id: 'desktopTopbar.appMenu.services',
defaultMessage: 'Services',
},
hide: { id: 'desktopTopbar.appMenu.hide', defaultMessage: 'Hide Notion' },
hideOthers: {
id: 'desktopTopbar.appMenu.hideOthers',
defaultMessage: 'Hide Others',
},
unhide: {
id: 'desktopTopbar.appMenu.unhide',
defaultMessage: 'Show All',
},
quitMac: { id: 'desktopTopbar.appMenu.quit', defaultMessage: 'Quit' },
}),
escapeAmpersand = (message) => message.replace(/&/g, '&&');
__exports.setupSystemMenu = (locale) => {
const intl = localizationHelper.createIntlShape(locale),
fileMenu = {
role: 'fileMenu',
label: escapeAmpersand(intl.formatMessage(menuMessages.fileMenuTitle)),
submenu: isMac
? [
{
label: escapeAmpersand(
intl.formatMessage(menuMessages.newWindow)
),
accelerator: 'CmdOrCtrl+Shift+N',
click: () => createWindow.createWindow(),
},
...(tabsEnabled
? [
{
role: 'close',
label: escapeAmpersand(
intl.formatMessage(menuMessages.closeWindow)
),
},
]
: []),
]
: [
{
label: escapeAmpersand(
intl.formatMessage(menuMessages.newWindow)
),
accelerator: 'CmdOrCtrl+Shift+N',
click: () => createWindow.createWindow(),
},
...(tabsEnabled
? [
{
role: 'quit',
label: escapeAmpersand(
intl.formatMessage(menuMessages.quit)
),
},
]
: []),
],
},
editMenu = {
role: 'editMenu',
label: escapeAmpersand(intl.formatMessage(menuMessages.editMenuTitle)),
submenu: isMac
? [
{
role: 'undo',
label: escapeAmpersand(intl.formatMessage(menuMessages.undo)),
},
{
role: 'redo',
label: escapeAmpersand(intl.formatMessage(menuMessages.redo)),
},
{ type: 'separator' },
{
role: 'cut',
label: escapeAmpersand(intl.formatMessage(menuMessages.cut)),
},
{
role: 'copy',
label: escapeAmpersand(intl.formatMessage(menuMessages.copy)),
},
{
role: 'paste',
label: escapeAmpersand(intl.formatMessage(menuMessages.paste)),
},
{
role: 'selectAll',
label: escapeAmpersand(
intl.formatMessage(menuMessages.selectAll)
),
},
{ type: 'separator' },
{
label: escapeAmpersand(intl.formatMessage(menuMessages.speech)),
submenu: [
{
role: 'startSpeaking',
label: escapeAmpersand(
intl.formatMessage(menuMessages.startSpeaking)
),
},
{
role: 'stopSpeaking',
label: escapeAmpersand(
intl.formatMessage(menuMessages.stopSpeaking)
),
},
],
},
]
: [
{
role: 'undo',
label: escapeAmpersand(intl.formatMessage(menuMessages.undo)),
},
{
role: 'redo',
label: escapeAmpersand(intl.formatMessage(menuMessages.redo)),
},
{ type: 'separator' },
{
role: 'cut',
label: escapeAmpersand(intl.formatMessage(menuMessages.cut)),
},
{
role: 'copy',
label: escapeAmpersand(intl.formatMessage(menuMessages.copy)),
},
{
role: 'paste',
label: escapeAmpersand(intl.formatMessage(menuMessages.paste)),
},
{ type: 'separator' },
{
role: 'selectAll',
label: escapeAmpersand(
intl.formatMessage(menuMessages.selectAll)
),
},
],
},
viewMenu = {
role: 'viewMenu',
label: escapeAmpersand(intl.formatMessage(menuMessages.viewMenuTitle)),
submenu: [
{
label: escapeAmpersand(intl.formatMessage(menuMessages.reload)),
accelerator: 'CmdOrCtrl+R',
click() {
const focusedWebContents = electron.webContents.getFocusedWebContents();
if (focusedWebContents) {
if (focusedWebContents.hostWebContents) {
for (const webContentsInstance of electron.webContents.getAllWebContents()) {
if (
webContentsInstance.hostWebContents ===
focusedWebContents.hostWebContents
) {
webContentsInstance.reload();
}
}
} else {
focusedWebContents.reload();
}
}
},
},
{
label: escapeAmpersand(
intl.formatMessage(menuMessages.toggleDevTools)
),
accelerator: isMac ? 'Alt+Command+I' : 'Ctrl+Shift+I',
click() {
let focusedWebContents = electron.webContents.getFocusedWebContents();
if (focusedWebContents) {
const focusedWebContentsUrl = focusedWebContents.getURL();
if (
focusedWebContentsUrl.startsWith('file://') &&
focusedWebContentsUrl.endsWith('/search.html')
) {
const notionWebviewWebContents = electron.webContents
.getAllWebContents()
.find(
(webContentsInstance) =>
webContentsInstance.hostWebContents ===
focusedWebContents.hostWebContents &&
webContentsInstance !== focusedWebContents
);
if (notionWebviewWebContents) {
focusedWebContents = notionWebviewWebContents;
}
}
focusedWebContents.toggleDevTools();
}
},
},
{
label: escapeAmpersand(
intl.formatMessage(menuMessages.toggleWindowDevTools)
),
accelerator: isMac ? 'Shift+Alt+Command+I' : 'Alt+Ctrl+Shift+I',
visible: false,
click(menuItem, focusedWindow) {
if (focusedWindow) {
focusedWindow.webContents.toggleDevTools();
}
},
},
{ type: 'separator' },
{
role: 'togglefullscreen',
label: escapeAmpersand(
intl.formatMessage(menuMessages.togglefullscreen)
),
},
],
},
windowMenu = {
role: 'windowMenu',
label: escapeAmpersand(
intl.formatMessage(menuMessages.windowMenuTitle)
),
submenu: isMac
? [
{
role: 'minimize',
label: escapeAmpersand(
intl.formatMessage(menuMessages.minimize)
),
},
{
role: 'zoom',
label: escapeAmpersand(intl.formatMessage(menuMessages.zoom)),
},
{ type: 'separator' },
{
role: 'front',
label: escapeAmpersand(intl.formatMessage(menuMessages.front)),
},
]
: [
{
role: 'minimize',
label: escapeAmpersand(
intl.formatMessage(menuMessages.minimize)
),
},
{
label: escapeAmpersand(
intl.formatMessage(menuMessages.maximize)
),
click(item, focusedWindow) {
if (focusedWindow) {
if (focusedWindow.isMaximized()) {
focusedWindow.unmaximize();
} else {
focusedWindow.maximize();
}
}
},
},
...(tabsEnabled
? [
{
role: 'close',
label: escapeAmpersand(
intl.formatMessage(menuMessages.close)
),
},
]
: []),
],
},
helpMenu = {
role: 'help',
label: escapeAmpersand(intl.formatMessage(menuMessages.helpTitle)),
submenu: [
{
label: escapeAmpersand(intl.formatMessage(menuMessages.help)),
click() {
electron.shell.openExternal(config.default.baseURL + '/help');
},
},
],
},
appMenu = {
role: 'appMenu',
submenu: [
{
role: 'about',
label: escapeAmpersand(intl.formatMessage(menuMessages.about)),
},
{ type: 'separator' },
{
label: escapeAmpersand(intl.formatMessage(menuMessages.reset)),
async click(item, focusedWindow) {
await fs.remove(electron.app.getPath('userData'));
electron.app.relaunch();
electron.app.exit();
},
},
{ type: 'separator' },
{
role: 'services',
label: escapeAmpersand(intl.formatMessage(menuMessages.services)),
},
{ type: 'separator' },
{
role: 'hide',
label: escapeAmpersand(intl.formatMessage(menuMessages.hide)),
},
{
role: 'hideOthers',
label: escapeAmpersand(intl.formatMessage(menuMessages.hideOthers)),
},
{
role: 'unhide',
label: escapeAmpersand(intl.formatMessage(menuMessages.unhide)),
},
...(tabsEnabled
? [
{ type: 'separator' },
{
role: 'quit',
label: escapeAmpersand(
intl.formatMessage(menuMessages.quitMac)
),
},
]
: []),
],
},
template = [fileMenu, editMenu, viewMenu, windowMenu, helpMenu];
if (isMac) template.unshift(appMenu);
const menu = electron.Menu.buildFromTemplate(template);
electron.Menu.setApplicationMenu(menu);
};
};

View File

@ -1,196 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
@import './css/buttons.css';
* {
box-sizing: border-box;
word-break: break-word;
text-decoration: none;
text-size-adjust: 100%;
font-family: var(--theme--font_sans) !important;
outline-color: var(--theme--table-border);
}
@keyframes spin {
from {
transform: rotate(0deg);
}
to {
transform: rotate(360deg);
}
}
@keyframes tabSlide {
from {
width: 0;
}
to {
width: 8.5em;
}
}
body:not(.error)::after {
z-index: 1;
content: '';
position: absolute;
left: calc(50% - 15px);
top: calc(50% + 10px);
width: 18px;
height: 18px;
opacity: 0.5;
border: 4px solid var(--theme--text);
border-top-color: transparent;
border-radius: 50%;
animation: spin 0.8s linear infinite;
}
html,
body,
#root {
background: var(--theme--main) !important;
position: relative;
height: 100%;
margin: 0;
}
#root {
display: flex;
flex-direction: column;
}
[data-platform='darwin'] #titlebar {
padding-left: 4em;
}
#titlebar::before {
content: '';
position: absolute;
width: 100%;
-webkit-app-region: no-drag;
top: 0;
left: 0;
height: 2px;
}
#titlebar {
display: flex;
flex-shrink: 1;
user-select: none;
-webkit-app-region: drag;
background: var(--theme--dragarea);
}
#titlebar button {
color: var(--theme--text);
-webkit-app-region: no-drag;
border: none;
background: transparent;
}
#titlebar .window-buttons-area {
margin: 0.5em 0.55em 0.5em auto;
}
#titlebar .window-buttons-area:empty {
display: none;
}
#open-enhancer-menu::before {
content: '';
height: 1.25em;
width: 1.25em;
display: inline-block;
margin: auto 1em -0.25em 1em;
background-size: contain;
background-image: url('enhancement://core/icons/mac+linux.png');
background-repeat: no-repeat;
}
#tabs {
margin-top: auto;
flex-wrap: wrap;
display: flex;
align-items: center;
}
#tabs .tab:not(.new):not(.current) {
flex: 1 1 30px;
min-width: 30px;
}
#tabs button:nth-child(16) {
display: none;
opacity: 0;
}
#tabs .tab {
display: inline-flex;
background: var(--theme--main);
border: none;
font-size: 1.15em;
padding: 0.2em 0.4em;
text-align: left;
border-bottom: 0.22em solid var(--theme--table-border);
opacity: 0.8;
}
#tabs .tab img {
object-fit: cover;
height: 1em;
width: 1em;
border-radius: 3px;
margin: 0 0.5em -0.16em 0.1em;
}
#tabs .tab:not(.new) {
margin-top: 0.5em;
}
#tabs .tab:not(.new) span:not(.close) {
width: 8.5em;
margin-right: 0.22em;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#tabs .tab.slideIn span:not(.close) {
animation: tabSlide 100ms ease-in-out;
}
#tabs .tab.slideOut {
width: 0;
animation: tabSlide 100ms ease-in-out reverse;
}
#tabs .tab .close {
padding: 0 0.35em 0.1em 0.3em;
margin-left: auto;
font-weight: bold;
}
#tabs .tab.current {
opacity: 1;
background: var(--theme--selected);
border-bottom: 0.22em solid var(--theme--option_active-background);
}
#tabs .tab.new {
background: none;
border: none;
margin-left: -0.1em;
margin-top: 0.3em;
}
#tabs .tab.new span {
padding: 0 0.35em 0.1em 0.3em;
font-weight: bold;
}
#tabs .tab:hover {
opacity: 1;
}
#tabs .tab .close:hover,
#tabs .tab.new span:hover,
#titlebar .window-button:hover {
border-radius: 0.22em;
background: var(--theme--table-border);
box-shadow: 0 0 0 0.5px var(--theme--interactive_hover-border);
}
#titlebar .window-button.btn-close:hover {
background: var(--theme--button_close);
color: var(--theme--button_close-fill);
}
#tabs .tab.dragged-over {
box-shadow: inset 0.22em 0 0 0 var(--theme--selected);
}
.notion {
z-index: 2;
width: 100%;
height: 100%;
display: none;
}

View File

@ -1,261 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* under the MIT license
*/
'use strict';
let tray, enhancer_menu;
module.exports = (store, __exports) => {
const electron = require('electron'),
path = require('path'),
is_mac = process.platform === 'darwin',
is_win = process.platform === 'win32',
helpers = require('../../pkg/helpers.js'),
getAllWindows = electron.BrowserWindow.getAllWindows;
function newWindow() {
require('./createWindow.js')(
store,
require(path.resolve(
`${helpers.getNotionResources()}/app/main/createWindow.js`
))
)(
'',
getAllWindows().find((win) => win !== enhancer_menu)
);
}
electron.app.on('second-instance', (event, args, workingDirectory) => {
const windows = getAllWindows();
if (windows.some((win) => win.isVisible())) {
newWindow();
} else {
windows.forEach((window) => {
window.show();
window.focus();
if (store().maximized) window.maximize();
});
}
});
electron.app.once('ready', () => {
// tray
tray = new electron.Tray(
is_win
? path.resolve(`${__dirname}/icons/windows.ico`)
: new electron.nativeImage.createFromPath(
path.resolve(`${__dirname}/icons/mac+linux.png`)
).resize({
width: 16,
height: 16,
})
);
// menu
electron.ipcMain.on('enhancer:open-menu', openEnhancerMenu);
electron.ipcMain.on('enhancer:set-app-theme', (event, arg) => {
electron.webContents
.getAllWebContents()
.forEach((webContents) =>
webContents.send('enhancer:set-app-theme', arg)
);
});
electron.ipcMain.on('enhancer:get-app-theme', (event, arg) => {
electron.webContents
.getAllWebContents()
.forEach((webContents) =>
webContents.send('enhancer:get-app-theme', arg)
);
});
electron.ipcMain.on('enhancer:close-tab', (event, target, tab) => {
electron.webContents
.fromId(target)
.webContents.send('enhancer:close-tab', tab);
});
function calculateWindowPos(width, height) {
const screen = electron.screen.getDisplayNearestPoint({
x: tray.getBounds().x,
y: tray.getBounds().y,
});
// left
if (screen.workArea.x > 0)
return {
x: screen.workArea.x,
y: screen.workArea.height - height,
};
// top
if (screen.workArea.y > 0)
return {
x: Math.round(
tray.getBounds().x + tray.getBounds().width / 2 - width / 2
),
y: screen.workArea.y,
};
// right
if (screen.workArea.width < screen.bounds.width)
return {
x: screen.workArea.width - width,
y: screen.bounds.height - height,
};
// bottom
return {
x: Math.round(
tray.getBounds().x + tray.getBounds().width / 2 - width / 2
),
y: screen.workArea.height - height,
};
}
function openEnhancerMenu() {
if (enhancer_menu) return enhancer_menu.show();
const window_state = require(`${helpers
.getNotionResources()
.replace(/\\/g, '/')}/app/node_modules/electron-window-state/index.js`)(
{
file: 'menu.windowstate.json',
path: helpers.__data,
defaultWidth: 275,
defaultHeight: 600,
}
);
enhancer_menu = new electron.BrowserWindow({
show: true,
frame: !store().frameless,
titleBarStyle: 'hiddenInset',
x:
window_state.x ||
calculateWindowPos(window_state.width, window_state.height).x,
y:
window_state.y ||
calculateWindowPos(window_state.width, window_state.height).y,
width: window_state.width,
height: window_state.height,
webPreferences: {
preload: path.resolve(`${__dirname}/enhancerMenu.js`),
nodeIntegration: true,
session: electron.session.fromPartition('persist:notion'),
enableRemoteModule: true,
},
});
enhancer_menu.loadURL('enhancement://core/menu.html');
enhancer_menu.on('close', (e) => {
window_state.saveState(enhancer_menu);
enhancer_menu = null;
});
// enhancer_menu.webContents.openDevTools();
}
// tray
const contextMenu = electron.Menu.buildFromTemplate([
{
type: 'normal',
label: 'GitHub',
click: () => {
electron.shell.openExternal(
'https://github.com/notion-enhancer/notion-enhancer/blob/master/DOCUMENTATION.md'
);
},
},
{
type: 'normal',
label: 'Discord',
click: () => {
electron.shell.openExternal('https://discord.gg/sFWPXtA');
},
},
{
type: 'separator',
},
{
type: 'normal',
label: 'Bug Report',
click: () => {
electron.shell.openExternal(
'https://github.com/notion-enhancer/notion-enhancer/issues/new?labels=bug&template=bug-report.md'
);
},
},
{
type: 'normal',
label: 'Feature Proposal',
click: () => {
electron.shell.openExternal(
'https://github.com/notion-enhancer/notion-enhancer/issues/new?labels=enhancement&template=feature-proposal.md'
);
},
},
{
type: 'separator',
},
{
type: 'normal',
label: 'Enhancements',
accelerator: store().menu_toggle,
click: openEnhancerMenu,
},
{
type: 'normal',
label: 'New Window',
click: newWindow(),
accelerator: 'CommandOrControl+Shift+N',
},
{
type: 'normal',
label: 'Toggle Visibility',
accelerator: store().hotkey,
click: toggleWindows,
},
{
type: 'separator',
},
{
label: 'Relaunch',
click: () => {
electron.app.relaunch();
electron.app.quit();
},
},
{
label: 'Quit',
role: 'quit',
},
]);
tray.setContextMenu(contextMenu);
tray.setToolTip('Notion');
// hotkey
function showWindows(windows) {
if (is_mac) electron.app.show();
if (store().maximized) windows.forEach((win) => [win.maximize()]);
else windows.forEach((win) => win.show());
electron.app.focus({ steal: true });
}
function hideWindows(windows) {
windows.forEach((win) => [win.isFocused() && win.blur(), win.hide()]);
if (is_mac) electron.app.hide();
}
function toggleWindows() {
const windows = getAllWindows();
if (windows.some((win) => win.isVisible())) hideWindows(windows);
else showWindows(windows);
}
tray.on('click', toggleWindows);
if (store().hotkey) {
electron.globalShortcut.register(store().hotkey, () => {
const windows = getAllWindows();
if (windows.some((win) => win.isFocused() && win.isVisible()))
hideWindows(windows);
else showWindows(windows);
});
}
});
};

View File

@ -1,810 +0,0 @@
/*
* notion-enhancer
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 TarasokUA
* (c) 2020 Arecsu
* (c) 2020 u/zenith_illinois
* (c) 2020 admiraldus (https://github.com/admiraldus)
* under the MIT license
*/
:root {
/** dark **/
--theme_dark--main: rgb(47, 52, 55);
--theme_dark--sidebar: rgb(55, 60, 63);
--theme_dark--overlay: rgba(15, 15, 15, 0.6);
--theme_dark--dragarea: #272d2f;
--theme_dark--box-shadow: rgba(15, 15, 15, 0.2) 0px 0px 0px 1px,
rgba(15, 15, 15, 0.2) 0px 2px 4px;
--theme_dark--box-shadow_strong: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px,
rgba(15, 15, 15, 0.2) 0px 3px 6px, rgba(15, 15, 15, 0.4) 0px 9px 24px;
--theme_dark--page_normal-width: 900px;
--theme_dark--page_full-width: 100%;
--theme_dark--page-padding: calc(96px + env(safe-area-inset-left));
--theme_dark--page_banner-height: 30vh;
--theme_dark--preview-width: 977px;
--theme_dark--preview-padding: 8rem;
--theme_dark--preview_banner-height: 20vh;
--theme_dark--font_sans: -apple-system, BlinkMacSystemFont, 'Segoe UI',
Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji',
'Segoe UI Symbol';
--theme_dark--font_serif: Lyon-Text, Georgia, YuMincho, 'Yu Mincho',
'Hiragino Mincho ProN', 'Hiragino Mincho Pro', 'Songti TC', 'Songti SC',
SimSun, 'Nanum Myeongjo', NanumMyeongjo, Batang, serif;
--theme_dark--font_mono: iawriter-mono, Nitti, Menlo, Courier, monospace;
--theme_dark--font_code: SFMono-Regular, Consolas, 'Liberation Mono', Menlo,
Courier, monospace;
--theme_dark--font_quote: var(--theme_dark--font_sans);
--theme_dark--font_headings: var(--theme_dark--font_sans);
--theme_dark--font_title-size: 40px;
--theme_dark--font_heading1-size: 1.875em;
--theme_dark--font_heading2-size: 1.5em;
--theme_dark--font_heading3-size: 1.25em;
--theme_dark--font_label-size: 14px;
--theme_dark--font_body-size: 16px;
--theme_dark--font_body-size_small: 14px;
--theme_dark--font_code-size: 0.796875em;
--theme_dark--font_sidebar-size: 14px;
--theme_dark--text-block_line-height: 1.5;
--theme_dark--text-block_margin-top: 1px;
--theme_dark--scrollbar: #505457;
--theme_dark--scrollbar-border: transparent;
--theme_dark--scrollbar_hover: #696d6f;
--theme_dark--card: rgb(63, 68, 71);
--theme_dark--gallery: rgba(255, 255, 255, 0.05);
--theme_dark--select_input: rgb(55, 60, 63);
--theme_dark--table-border: rgba(255, 255, 255, 0.1);
--theme_dark--table-border_row: rgb(77, 81, 83);
--theme_dark--table-border_column: rgb(63, 66, 69);
--theme_dark--table-border_selected: rgba(46, 170, 220, 0.6);
--theme_dark--ui-border: rgba(255, 255, 255, 0.07);
--theme_dark--interactive_hover: rgb(71, 76, 80);
--theme_dark--interactive_hover-border: transparent;
--theme_dark--button_close: #e81123;
--theme_dark--button_close-fill: white;
--theme_dark--selected: rgba(46, 170, 220, 0.2);
--theme_dark--primary: rgb(46, 170, 220);
--theme_dark--primary_text: white;
--theme_dark--primary_hover: rgb(6, 156, 205);
--theme_dark--primary_click: rgb(0, 141, 190);
--theme_dark--primary_indicator: rgb(235, 87, 87);
--theme_dark--primary_indicator_text: var(--theme_dark--primary_text);
--theme_dark--primary_indicator_hover: rgba(45, 156, 219, 0.2);
--theme_dark--option-color: white;
--theme_dark--option-background: transparent;
--theme_dark--option_active-color: white;
--theme_dark--option_active-background: var(--theme_dark--primary);
--theme_dark--option_hover-color: white;
--theme_dark--option_hover-background: rgb(71, 76, 80);
--theme_dark--danger_text: rgb(235, 87, 87);
--theme_dark--danger_border: rgba(235, 87, 87, 0.5);
--theme_dark--divider: var(--theme_dark--table-border);
--theme_dark--text: rgba(255, 255, 255, 0.9);
--theme_dark--text_ui: rgba(255, 255, 255, 0.6);
--theme_dark--text_ui_info: rgba(255, 255, 255, 0.4);
--theme_dark--text_gray: rgba(151, 154, 155, 0.95);
--theme_dark--text_brown: rgb(147, 114, 100);
--theme_dark--text_orange: rgb(255, 163, 68);
--theme_dark--text_yellow: rgb(255, 220, 73);
--theme_dark--text_green: rgb(77, 171, 154);
--theme_dark--text_blue: rgb(82, 156, 202);
--theme_dark--text_purple: rgb(154, 109, 215);
--theme_dark--text_pink: rgb(226, 85, 161);
--theme_dark--text_red: rgb(255, 115, 105);
--theme_dark--bg-text: var(--theme_dark--text);
--theme_dark--bg_gray: rgb(69, 75, 78);
--theme_dark--bg_gray-text: var(--theme_dark--bg-text);
--theme_dark--bg_brown: rgb(67, 64, 64);
--theme_dark--bg_brown-text: var(--theme_dark--bg-text);
--theme_dark--bg_orange: rgb(89, 74, 58);
--theme_dark--bg_orange-text: var(--theme_dark--bg-text);
--theme_dark--bg_yellow: rgb(89, 86, 59);
--theme_dark--bg_yellow-text: var(--theme_dark--bg-text);
--theme_dark--bg_green: rgb(53, 76, 75);
--theme_dark--bg_green-text: var(--theme_dark--bg-text);
--theme_dark--bg_blue: rgb(54, 73, 84);
--theme_dark--bg_blue-text: var(--theme_dark--bg-text);
--theme_dark--bg_purple: rgb(68, 63, 87);
--theme_dark--bg_purple-text: var(--theme_dark--bg-text);
--theme_dark--bg_pink: rgb(83, 59, 76);
--theme_dark--bg_pink-text: var(--theme_dark--bg-text);
--theme_dark--bg_red: rgb(89, 65, 65);
--theme_dark--bg_red-text: var(--theme_dark--bg-text);
--theme_dark--line-text: var(--theme_dark--text);
--theme_dark--line_gray: rgb(69, 75, 78);
--theme_dark--line_gray-text: var(--theme_dark--line-text);
--theme_dark--line_brown: rgb(67, 64, 64);
--theme_dark--line_brown-text: var(--theme_dark--line-text);
--theme_dark--line_orange: rgb(89, 74, 58);
--theme_dark--line_orange-text: var(--theme_dark--line-text);
--theme_dark--line_yellow: rgb(89, 86, 59);
--theme_dark--line_yellow-text: var(--theme_dark--line-text);
--theme_dark--line_green: rgb(53, 76, 75);
--theme_dark--line_green-text: var(--theme_dark--line-text);
--theme_dark--line_blue: rgb(54, 73, 84);
--theme_dark--line_blue-text: var(--theme_dark--line-text);
--theme_dark--line_purple: rgb(68, 63, 87);
--theme_dark--line_purple-text: var(--theme_dark--line-text);
--theme_dark--line_pink: rgb(83, 59, 76);
--theme_dark--line_pink-text: var(--theme_dark--line-text);
--theme_dark--line_red: rgb(89, 65, 65);
--theme_dark--line_red-text: var(--theme_dark--line-text);
--theme_dark--select-text: var(--theme_dark--text);
--theme_dark--select_gray: rgba(151, 154, 155, 0.5);
--theme_dark--select_gray-text: var(--theme_dark--select-text);
--theme_dark--select_brown: rgba(147, 114, 100, 0.5);
--theme_dark--select_brown-text: var(--theme_dark--select-text);
--theme_dark--select_orange: rgba(255, 163, 68, 0.5);
--theme_dark--select_orange-text: var(--theme_dark--select-text);
--theme_dark--select_yellow: rgba(255, 220, 73, 0.5);
--theme_dark--select_yellow-text: var(--theme_dark--select-text);
--theme_dark--select_green: rgba(77, 171, 154, 0.5);
--theme_dark--select_green-text: var(--theme_dark--select-text);
--theme_dark--select_blue: rgba(82, 156, 202, 0.5);
--theme_dark--select_blue-text: var(--theme_dark--select-text);
--theme_dark--select_purple: rgba(154, 109, 215, 0.5);
--theme_dark--select_purple-text: var(--theme_dark--select-text);
--theme_dark--select_pink: rgba(226, 85, 161, 0.5);
--theme_dark--select_pink-text: var(--theme_dark--select-text);
--theme_dark--select_red: rgba(255, 115, 105, 0.5);
--theme_dark--select_red-text: var(--theme_dark--select-text);
--theme_dark--callout-text: var(--theme_dark--text);
--theme_dark--callout_gray: rgba(69, 75, 78, 0.3);
--theme_dark--callout_gray-text: var(--theme_dark--callout-text);
--theme_dark--callout_brown: rgba(67, 64, 64, 0.3);
--theme_dark--callout_brown-text: var(--theme_dark--callout-text);
--theme_dark--callout_orange: rgba(89, 74, 58, 0.3);
--theme_dark--callout_orange-text: var(--theme_dark--callout-text);
--theme_dark--callout_yellow: rgba(89, 86, 59, 0.3);
--theme_dark--callout_yellow-text: var(--theme_dark--callout-text);
--theme_dark--callout_green: rgba(53, 76, 75, 0.3);
--theme_dark--callout_green-text: var(--theme_dark--callout-text);
--theme_dark--callout_blue: rgba(54, 73, 84, 0.3);
--theme_dark--callout_blue-text: var(--theme_dark--callout-text);
--theme_dark--callout_purple: rgba(68, 63, 87, 0.3);
--theme_dark--callout_purple-text: var(--theme_dark--callout-text);
--theme_dark--callout_pink: rgba(83, 59, 76, 0.3);
--theme_dark--callout_pink-text: var(--theme_dark--callout-text);
--theme_dark--callout_red: rgba(89, 65, 65, 0.3);
--theme_dark--callout_red-text: var(--theme_dark--callout-text);
--theme_dark--code_inline-text: #eb5757;
--theme_dark--code_inline-background: rgba(135, 131, 120, 0.15);
--theme_dark--code-text: var(--theme_dark--text);
--theme_dark--code-background: var(--theme_dark--card);
--theme_dark--code_function: var(--theme_dark--code-text);
--theme_dark--code_parameter: var(--theme_dark--code-text);
--theme_dark--code_keyword: hsl(350, 40%, 70%);
--theme_dark--code_constant: hsl(350, 40%, 70%);
--theme_dark--code_tag: hsl(350, 40%, 70%);
--theme_dark--code_operator: hsl(40, 90%, 60%);
--theme_dark--code_important: #e90;
--theme_dark--code_regex: #e90;
--theme_dark--code_property: hsl(350, 40%, 70%);
--theme_dark--code_builtin: hsl(75, 70%, 60%);
--theme_dark--code_class-name: var(--theme_dark--code-text);
--theme_dark--code_attr-name: hsl(75, 70%, 60%);
--theme_dark--code_attr-value: hsl(350, 40%, 70%);
--theme_dark--code_selector: hsl(75, 70%, 60%);
--theme_dark--code_id: var(--theme_dark--code-text);
--theme_dark--code_class: var(--theme_dark--code-text);
--theme_dark--code_pseudo-element: var(--theme_dark--code-text);
--theme_dark--code_pseudo-class: var(--theme_dark--code-text);
--theme_dark--code_attribute: var(--theme_dark--code-text);
--theme_dark--code_value: var(--theme_dark--code-text);
--theme_dark--code_unit: var(--theme_dark--code-text);
--theme_dark--code_comment: hsl(30, 20%, 50%);
--theme_dark--code_punctuation: var(--theme_dark--code-text);
--theme_dark--code_annotation: var(--theme_dark--code_punctuation);
--theme_dark--code_decorator: var(--theme_dark--code_punctuation);
--theme_dark--code_doctype: hsl(30, 20%, 50%);
--theme_dark--code_number: hsl(350, 40%, 70%);
--theme_dark--code_string: hsl(75, 70%, 60%);
--theme_dark--code_boolean: hsl(350, 40%, 70%);
/** light **/
--theme_light--main: white;
--theme_light--sidebar: rgb(247, 246, 243);
--theme_light--overlay: rgba(15, 15, 15, 0.6);
--theme_light--dragarea: rgba(55, 53, 47, 0.04);
--theme_light--box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px,
rgba(15, 15, 15, 0.1) 0px 2px 4px;
--theme_light--box-shadow_strong: rgba(15, 15, 15, 0.05) 0px 0px 0px 1px,
rgba(15, 15, 15, 0.1) 0px 3px 6px, rgba(15, 15, 15, 0.2) 0px 9px 24px;
--theme_light--page_normal-width: 900px;
--theme_light--page_full-width: 100%;
--theme_light--page-padding: calc(96px + env(safe-area-inset-left));
--theme_light--page_banner-height: 30vh;
--theme_light--preview-width: 977px;
--theme_light--preview-padding: 8rem;
--theme_light--preview_banner-height: 20vh;
--theme_light--font_sans: -apple-system, BlinkMacSystemFont, 'Segoe UI',
Helvetica, 'Apple Color Emoji', Arial, sans-serif, 'Segoe UI Emoji',
'Segoe UI Symbol';
--theme_light--font_serif: Lyon-Text, Georgia, YuMincho, 'Yu Mincho',
'Hiragino Mincho ProN', 'Hiragino Mincho Pro', 'Songti TC', 'Songti SC',
SimSun, 'Nanum Myeongjo', NanumMyeongjo, Batang, serif;
--theme_light--font_mono: iawriter-mono, Nitti, Menlo, Courier, monospace;
--theme_light--font_code: SFMono-Regular, Consolas, 'Liberation Mono', Menlo,
Courier, monospace;
--theme_light--font_quote: var(--theme_light--font_sans);
--theme_light--font_headings: var(--theme_light--font_sans);
--theme_light--font_title-size: 40px;
--theme_light--font_heading1-size: 1.875em;
--theme_light--font_heading2-size: 1.5em;
--theme_light--font_heading3-size: 1.25em;
--theme_light--font_label-size: 14px;
--theme_light--font_body-size: 16px;
--theme_light--font_body-size_small: 14px;
--theme_light--font_code-size: 0.796875em;
--theme_light--font_sidebar-size: 14px;
--theme_light--text-block_line-height: 1.5;
--theme_light--text-block_margin-top: 1px;
--theme_light--scrollbar: #d9d8d6;
--theme_light--scrollbar-border: #cacac8;
--theme_light--scrollbar_hover: #cacac8;
--theme_light--card: rgb(247, 247, 247);
--theme_light--gallery: rgba(55, 53, 47, 0.024);
--theme_light--select_input: rgba(242, 241, 238, 0.6);
--theme_light--table-border: rgba(55, 53, 47, 0.16);
--theme_light--table-border_row: rgb(223, 223, 222);
--theme_light--table-border_column: rgb(237, 237, 236);
--theme_light--table-border_selected: rgba(46, 170, 220, 0.6);
--theme_light--ui-border: rgba(55, 53, 47, 0.09);
--theme_light--interactive_hover: rgb(239, 239, 239);
--theme_light--interactive_hover-border: transparent;
--theme_light--button_close: #e81123;
--theme_light--button_close-fill: white;
--theme_light--selected: rgba(46, 170, 220, 0.2);
--theme_light--primary: rgb(46, 170, 220);
--theme_light--primary_text: white;
--theme_light--primary_hover: rgb(6, 156, 205);
--theme_light--primary_click: rgb(0, 141, 190);
--theme_light--primary_indicator: rgb(235, 87, 87);
--theme_light--primary_indicator_text: var(--theme_light--primary_text);
--theme_light--primary_indicator_hover: rgba(45, 156, 219, 0.2);
--theme_light--option-color: black;
--theme_light--option-background: transparent;
--theme_light--option_hover-color: black;
--theme_light--option_hover-background: rgba(55, 53, 47, 0.08);
--theme_light--option_active-color: white;
--theme_light--option_active-background: var(--theme_light--primary);
--theme_light--danger_text: rgb(235, 87, 87);
--theme_light--danger_border: rgba(235, 87, 87, 0.5);
--theme_light--divider: var(--theme_light--table-border);
--theme_light--text: rgb(55, 53, 47);
--theme_light--text_ui: rgba(55, 53, 47, 0.6);
--theme_light--text_ui: rgba(55, 53, 47, 0.6);
--theme_light--text_ui_info: rgba(55, 53, 47, 0.4);
--theme_light--text_gray: rgb(155, 154, 151);
--theme_light--text_brown: rgb(100, 71, 58);
--theme_light--text_orange: rgb(217, 115, 13);
--theme_light--text_yellow: rgb(223, 171, 1);
--theme_light--text_green: rgb(15, 123, 108);
--theme_light--text_blue: rgb(11, 110, 153);
--theme_light--text_purple: rgb(105, 64, 165);
--theme_light--text_pink: rgb(173, 26, 114);
--theme_light--text_red: rgb(224, 62, 62);
--theme_light--bg-text: var(--theme_light--text);
--theme_light--bg_gray: rgb(235, 236, 237);
--theme_light--bg_gray-text: var(--theme_light--bg-text);
--theme_light--bg_brown: rgb(233, 229, 227);
--theme_light--bg_brown-text: var(--theme_light--bg-text);
--theme_light--bg_orange: rgb(250, 235, 221);
--theme_light--bg_orange-text: var(--theme_light--bg-text);
--theme_light--bg_yellow: rgb(251, 243, 219);
--theme_light--bg_yellow-text: var(--theme_light--bg-text);
--theme_light--bg_green: rgb(221, 237, 234);
--theme_light--bg_green-text: var(--theme_light--bg-text);
--theme_light--bg_blue: rgb(221, 235, 241);
--theme_light--bg_blue-text: var(--theme_light--bg-text);
--theme_light--bg_purple: rgb(234, 228, 242);
--theme_light--bg_purple-text: var(--theme_light--bg-text);
--theme_light--bg_pink: rgb(244, 223, 235);
--theme_light--bg_pink-text: var(--theme_light--bg-text);
--theme_light--bg_red: rgb(251, 228, 228);
--theme_light--bg_red-text: var(--theme_light--bg-text);
--theme_light--line-text: var(--theme_light--text);
--theme_light--line_gray: rgb(235, 236, 237);
--theme_light--line_gray-text: var(--theme_light--line-text);
--theme_light--line_brown: rgb(233, 229, 227);
--theme_light--line_brown-text: var(--theme_light--line-text);
--theme_light--line_orange: rgb(250, 235, 221);
--theme_light--line_orange-text: var(--theme_light--line-text);
--theme_light--line_yellow: rgb(251, 243, 219);
--theme_light--line_yellow-text: var(--theme_light--line-text);
--theme_light--line_green: rgb(221, 237, 234);
--theme_light--line_green-text: var(--theme_light--line-text);
--theme_light--line_blue: rgb(221, 235, 241);
--theme_light--line_blue-text: var(--theme_light--line-text);
--theme_light--line_purple: rgb(234, 228, 242);
--theme_light--line_purple-text: var(--theme_light--line-text);
--theme_light--line_pink: rgb(244, 223, 235);
--theme_light--line_pink-text: var(--theme_light--line-text);
--theme_light--line_red: rgb(251, 228, 228);
--theme_light--line_red-text: var(--theme_light--line-text);
--theme_light--select-text: var(--theme_light--text);
--theme_light--select_gray: rgba(140, 46, 0, 0.2);
--theme_light--select_gray-text: var(--theme_light--select-text);
--theme_light--select_brown: rgba(140, 46, 0, 0.2);
--theme_light--select_brown-text: var(--theme_light--select-text);
--theme_light--select_orange: rgba(245, 93, 0, 0.2);
--theme_light--select_orange-text: var(--theme_light--select-text);
--theme_light--select_yellow: rgba(233, 168, 0, 0.2);
--theme_light--select_yellow-text: var(--theme_light--select-text);
--theme_light--select_green: rgba(0, 135, 107, 0.2);
--theme_light--select_green-text: var(--theme_light--select-text);
--theme_light--select_blue: rgba(0, 120, 223, 0.2);
--theme_light--select_blue-text: var(--theme_light--select-text);
--theme_light--select_purple: rgba(103, 36, 222, 0.2);
--theme_light--select_purple-text: var(--theme_light--select-text);
--theme_light--select_pink: rgba(221, 0, 129, 0.2);
--theme_light--select_pink-text: var(--theme_light--select-text);
--theme_light--select_red: rgba(255, 0, 26, 0.2);
--theme_light--select_red-text: var(--theme_light--select-text);
--theme_light--callout-text: var(--theme_light--text);
--theme_light--callout_gray: rgba(235, 236, 237, 0.3);
--theme_light--callout_gray-text: var(--theme_light--callout-text);
--theme_light--callout_brown: rgba(233, 229, 227, 0.3);
--theme_light--callout_brown-text: var(--theme_light--callout-text);
--theme_light--callout_orange: rgba(250, 235, 221, 0.3);
--theme_light--callout_orange-text: var(--theme_light--callout-text);
--theme_light--callout_yellow: rgba(251, 243, 219, 0.3);
--theme_light--callout_yellow-text: var(--theme_light--callout-text);
--theme_light--callout_green: rgba(221, 237, 234, 0.3);
--theme_light--callout_green-text: var(--theme_light--callout-text);
--theme_light--callout_blue: rgba(221, 235, 241, 0.3);
--theme_light--callout_blue-text: var(--theme_light--callout-text);
--theme_light--callout_purple: rgba(234, 228, 242, 0.3);
--theme_light--callout_purple-text: var(--theme_light--callout-text);
--theme_light--callout_pink: rgba(244, 223, 235, 0.3);
--theme_light--callout_pink-text: var(--theme_light--callout-text);
--theme_light--callout_red: rgba(251, 228, 228, 0.3);
--theme_light--callout_red-text: var(--theme_light--callout-text);
--theme_light--code_inline-text: #eb5757;
--theme_light--code_inline-background: rgba(135, 131, 120, 0.15);
--theme_light--code-text: var(--theme_light--text);
--theme_light--code-background: var(--theme_light--card);
--theme_light--code_function: #dd4a68;
--theme_light--code_parameter: var(--theme_light--code-text);
--theme_light--code_keyword: #07a;
--theme_light--code_constant: #905;
--theme_light--code_tag: #905;
--theme_light--code_operator: #9a6e3a;
--theme_light--code_important: #e90;
--theme_light--code_regex: #e90;
--theme_light--code_property: #905;
--theme_light--code_builtin: #690;
--theme_light--code_class-name: #dd4a68;
--theme_light--code_attr-name: #690;
--theme_light--code_attr-value: #07a;
--theme_light--code_selector: #690;
--theme_light--code_id: var(--theme_light--code-text);
--theme_light--code_class: var(--theme_light--code-text);
--theme_light--code_pseudo-element: var(--theme_light--code-text);
--theme_light--code_pseudo-class: var(--theme_light--code-text);
--theme_light--code_attribute: var(--theme_light--code-text);
--theme_light--code_value: var(--theme_light--code-text);
--theme_light--code_unit: var(--theme_light--code-text);
--theme_light--code_comment: slategray;
--theme_light--code_punctuation: #999;
--theme_light--code_annotation: var(--theme_light--code_punctuation);
--theme_light--code_decorator: var(--theme_light--code_punctuation);
--theme_light--code_doctype: slategray;
--theme_light--code_number: #905;
--theme_light--code_string: #690;
--theme_light--code_boolean: #905;
}
.notion-dark-theme {
--theme--main: var(--theme_dark--main);
--theme--sidebar: var(--theme_dark--sidebar);
--theme--overlay: var(--theme_dark--overlay);
--theme--dragarea: var(--theme_dark--dragarea);
--theme--box-shadow: var(--theme_dark--box-shadow);
--theme--box-shadow_strong: var(--theme_dark--box-shadow_strong);
--theme--page_normal-width: var(--theme_dark--page_normal-width);
--theme--page_full-width: var(--theme_dark--page_full-width);
--theme--page-padding: var(--theme_dark--page-padding);
--theme--page_banner-height: var(--theme_dark--page_banner-height);
--theme--preview-width: var(--theme_dark--preview-width);
--theme--preview-padding: var(--theme_dark--preview-padding);
--theme--preview_banner-height: var(--theme_dark--preview_banner-height);
--theme--font_sans: var(--theme_dark--font_sans);
--theme--font_serif: var(--theme_dark--font_serif);
--theme--font_mono: var(--theme_dark--font_mono);
--theme--font_code: var(--theme_dark--font_code);
--theme--font_quote: var(--theme_dark--font_quote);
--theme--font_headings: var(--theme_dark--font_headings);
--theme--font_title-size: var(--theme_dark--font_title-size);
--theme--font_heading1-size: var(--theme_dark--font_heading1-size);
--theme--font_heading2-size: var(--theme_dark--font_heading2-size);
--theme--font_heading3-size: var(--theme_dark--font_heading3-size);
--theme--font_label-size: var(--theme_dark--font_label-size);
--theme--font_body-size: var(--theme_dark--font_body-size);
--theme--font_body-size_small: var(--theme_dark--font_body-size_small);
--theme--font_code-size: var(--theme_dark--font_code-size);
--theme--font_sidebar-size: var(--theme_dark--font_sidebar-size);
--theme--text-block_line-height: var(--theme_dark--text-block_line-height);
--theme--text-block_margin-top: var(--theme_dark--text-block_margin-top);
--theme--scrollbar: var(--theme_dark--scrollbar);
--theme--scrollbar-border: var(--theme_dark--scrollbar-border);
--theme--scrollbar_hover: var(--theme_dark--scrollbar_hover);
--theme--card: var(--theme_dark--card);
--theme--gallery: var(--theme_dark--gallery);
--theme--select_input: var(--theme_dark--select_input);
--theme--table-border: var(--theme_dark--table-border);
--theme--table-border_row: var(--theme_dark--table-border_row);
--theme--table-border_column: var(--theme_dark--table-border_column);
--theme--table-border_selected: var(--theme_dark--table-border_selected);
--theme--ui-border: var(--theme_dark--ui-border);
--theme--interactive_hover: var(--theme_dark--interactive_hover);
--theme--interactive_hover-border: var(
--theme_dark--interactive_hover-border
);
--theme--button_close: var(--theme_dark--button_close);
--theme--button_close-fill: var(--theme_dark--button_close-fill);
--theme--selected: var(--theme_dark--selected);
--theme--primary: var(--theme_dark--primary);
--theme--primary_text: var(--theme_dark--primary_text);
--theme--primary_hover: var(--theme_dark--primary_hover);
--theme--primary_click: var(--theme_dark--primary_click);
--theme--primary_indicator: var(--theme_dark--primary_indicator);
--theme--primary_indicator_text: var(--theme_dark--primary_indicator_text);
--theme--primary_indicator_hover: var(--theme_dark--primary_indicator_hover);
--theme--option-color: var(--theme_dark--option-color);
--theme--option-background: var(--theme_dark--option-background);
--theme--option_active-color: var(--theme_dark--option_active-color);
--theme--option_active-background: var(
--theme_dark--option_active-background
);
--theme--option_hover-color: var(--theme_dark--option_hover-color);
--theme--option_hover-background: var(--theme_dark--option_hover-background);
--theme--danger_text: var(--theme_dark--danger_text);
--theme--danger_border: var(--theme_dark--danger_border);
--theme--divider: var(--theme_dark--divider);
--theme--text: var(--theme_dark--text);
--theme--text_ui: var(--theme_dark--text_ui);
--theme--text_ui_info: var(--theme_dark--text_ui_info);
--theme--text_gray: var(--theme_dark--text_gray);
--theme--text_brown: var(--theme_dark--text_brown);
--theme--text_orange: var(--theme_dark--text_orange);
--theme--text_yellow: var(--theme_dark--text_yellow);
--theme--text_green: var(--theme_dark--text_green);
--theme--text_blue: var(--theme_dark--text_blue);
--theme--text_purple: var(--theme_dark--text_purple);
--theme--text_pink: var(--theme_dark--text_pink);
--theme--text_red: var(--theme_dark--text_red);
--theme--select-text: var(--theme_dark--select-text);
--theme--bg-text: var(--theme_dark--bg-text);
--theme--bg_gray: var(--theme_dark--bg_gray);
--theme--bg_gray-text: var(--theme_dark--bg_gray-text);
--theme--bg_brown: var(--theme_dark--bg_brown);
--theme--bg_brown-text: var(--theme_dark--bg_brown-text);
--theme--bg_orange: var(--theme_dark--bg_orange);
--theme--bg_orange-text: var(--theme_dark--bg_orange-text);
--theme--bg_yellow: var(--theme_dark--bg_yellow);
--theme--bg_yellow-text: var(--theme_dark--bg_yellow-text);
--theme--bg_green: var(--theme_dark--bg_green);
--theme--bg_green-text: var(--theme_dark--bg_green-text);
--theme--bg_blue: var(--theme_dark--bg_blue);
--theme--bg_blue-text: var(--theme_dark--bg_blue-text);
--theme--bg_purple: var(--theme_dark--bg_purple);
--theme--bg_purple-text: var(--theme_dark--bg_purple-text);
--theme--bg_pink: var(--theme_dark--bg_pink);
--theme--bg_pink-text: var(--theme_dark--bg_pink-text);
--theme--bg_red: var(--theme_dark--bg_red);
--theme--bg_red-text: var(--theme_dark--bg_red-text);
--theme--line-text: var(--theme_dark--line-text);
--theme--line_gray: var(--theme_dark--line_gray);
--theme--line_gray-text: var(--theme_dark--line_gray-text);
--theme--line_brown: var(--theme_dark--line_brown);
--theme--line_brown-text: var(--theme_dark--line_brown-text);
--theme--line_orange: var(--theme_dark--line_orange);
--theme--line_orange-text: var(--theme_dark--line_orange-text);
--theme--line_yellow: var(--theme_dark--line_yellow);
--theme--line_yellow-text: var(--theme_dark--line_yellow-text);
--theme--line_green: var(--theme_dark--line_green);
--theme--line_green-text: var(--theme_dark--line_green-text);
--theme--line_blue: var(--theme_dark--line_blue);
--theme--line_blue-text: var(--theme_dark--line_blue-text);
--theme--line_purple: var(--theme_dark--line_purple);
--theme--line_purple-text: var(--theme_dark--line_purple-text);
--theme--line_pink: var(--theme_dark--line_pink);
--theme--line_pink-text: var(--theme_dark--line_pink-text);
--theme--line_red: var(--theme_dark--line_red);
--theme--line_red-text: var(--theme_dark--line_red-text);
--theme--select_gray: var(--theme_dark--select_gray);
--theme--select_gray-text: var(--theme_dark--select_gray-text);
--theme--select_brown: var(--theme_dark--select_brown);
--theme--select_brown-text: var(--theme_dark--select_brown-text);
--theme--select_orange: var(--theme_dark--select_orange);
--theme--select_orange-text: var(--theme_dark--select_orange-text);
--theme--select_yellow: var(--theme_dark--select_yellow);
--theme--select_yellow-text: var(--theme_dark--select_yellow-text);
--theme--select_green: var(--theme_dark--select_green);
--theme--select_green-text: var(--theme_dark--select_green-text);
--theme--select_blue: var(--theme_dark--select_blue);
--theme--select_blue-text: var(--theme_dark--select_blue-text);
--theme--select_purple: var(--theme_dark--select_purple);
--theme--select_purple-text: var(--theme_dark--select_purple-text);
--theme--select_pink: var(--theme_dark--select_pink);
--theme--select_pink-text: var(--theme_dark--select_pink-text);
--theme--select_red: var(--theme_dark--select_red);
--theme--select_red-text: var(--theme_dark--select_red-text);
--theme--callout-text: var(--theme_dark--callout-text);
--theme--callout_gray: var(--theme_dark--callout_gray);
--theme--callout_gray-text: var(--theme_dark--callout_gray-text);
--theme--callout_brown: var(--theme_dark--callout_brown);
--theme--callout_brown-text: var(--theme_dark--callout_brown-text);
--theme--callout_orange: var(--theme_dark--callout_orange);
--theme--callout_orange-text: var(--theme_dark--callout_orange-text);
--theme--callout_yellow: var(--theme_dark--callout_yellow);
--theme--callout_yellow-text: var(--theme_dark--callout_yellow-text);
--theme--callout_green: var(--theme_dark--callout_green);
--theme--callout_green-text: var(--theme_dark--callout_green-text);
--theme--callout_blue: var(--theme_dark--callout_blue);
--theme--callout_blue-text: var(--theme_dark--callout_blue-text);
--theme--callout_purple: var(--theme_dark--callout_purple);
--theme--callout_purple-text: var(--theme_dark--callout_purple-text);
--theme--callout_pink: var(--theme_dark--callout_pink);
--theme--callout_pink-text: var(--theme_dark--callout_pink-text);
--theme--callout_red: var(--theme_dark--callout_red);
--theme--callout_red-text: var(--theme_dark--callout_red-text);
--theme--code_inline-text: var(--theme_dark--code_inline-text);
--theme--code_inline-background: var(--theme_dark--code_inline-background);
--theme--code-text: var(--theme_dark--code-text);
--theme--code-background: var(--theme_dark--code-background);
--theme--code_function: var(--theme_dark--code_function);
--theme--code_parameter: var(--theme_dark--code_parameter);
--theme--code_keyword: var(--theme_dark--code_keyword);
--theme--code_constant: var(--theme_dark--code_constant);
--theme--code_tag: var(--theme_dark--code_tag);
--theme--code_operator: var(--theme_dark--code_operator);
--theme--code_important: var(--theme_dark--code_important);
--theme--code_regex: var(--theme_dark--code_regex);
--theme--code_property: var(--theme_dark--code_property);
--theme--code_builtin: var(--theme_dark--code_builtin);
--theme--code_class-name: var(--theme_dark--code_class-name);
--theme--code_attr-name: var(--theme_dark--code_attr-name);
--theme--code_attr-value: var(--theme_dark--code_attr-value);
--theme--code_selector: var(--theme_dark--code_selector);
--theme--code_id: var(--theme_dark--code_id);
--theme--code_class: var(--theme_dark--code_class);
--theme--code_pseudo-element: var(--theme_dark--code_pseudo-element);
--theme--code_pseudo-class: var(--theme_dark--code_pseudo-class);
--theme--code_attribute: var(--theme_dark--code_attribute);
--theme--code_value: var(--theme_dark--code_value);
--theme--code_unit: var(--theme_dark--code_unit);
--theme--code_comment: var(--theme_dark--code_comment);
--theme--code_punctuation: var(--theme_dark--code_punctuation);
--theme--code_annotation: var(--theme_dark--code_annotation);
--theme--code_decorator: var(--theme_dark--code_decorator);
--theme--code_doctype: var(--theme_dark--code_doctype);
--theme--code_number: var(--theme_dark--code_number);
--theme--code_string: var(--theme_dark--code_string);
--theme--code_boolean: var(--theme_dark--code_boolean);
}
.notion-light-theme {
--theme--main: var(--theme_light--main);
--theme--sidebar: var(--theme_light--sidebar);
--theme--overlay: var(--theme_light--overlay);
--theme--dragarea: var(--theme_light--dragarea);
--theme--box-shadow: var(--theme_light--box-shadow);
--theme--box-shadow_strong: var(--theme_light--box-shadow_strong);
--theme--page_normal-width: var(--theme_light--page_normal-width);
--theme--page_full-width: var(--theme_light--page_full-width);
--theme--page-padding: var(--theme_light--page-padding);
--theme--page_banner-height: var(--theme_light--page_banner-height);
--theme--preview-width: var(--theme_light--preview-width);
--theme--preview-padding: var(--theme_light--preview-padding);
--theme--preview_banner-height: var(--theme_light--preview_banner-height);
--theme--font_sans: var(--theme_light--font_sans);
--theme--font_serif: var(--theme_light--font_serif);
--theme--font_mono: var(--theme_light--font_mono);
--theme--font_code: var(--theme_light--font_code);
--theme--font_quote: var(--theme_light--font_quote);
--theme--font_headings: var(--theme_light--font_headings);
--theme--font_title-size: var(--theme_light--font_title-size);
--theme--font_heading1-size: var(--theme_light--font_heading1-size);
--theme--font_heading2-size: var(--theme_light--font_heading2-size);
--theme--font_heading3-size: var(--theme_light--font_heading3-size);
--theme--font_label-size: var(--theme_light--font_label-size);
--theme--font_body-size: var(--theme_light--font_body-size);
--theme--font_body-size_small: var(--theme_light--font_body-size_small);
--theme--font_code-size: var(--theme_light--font_code-size);
--theme--font_sidebar-size: var(--theme_light--font_sidebar-size);
--theme--text-block_line-height: var(--theme_light--text-block_line-height);
--theme--text-block_margin-top: var(--theme_light--text-block_margin-top);
--theme--scrollbar: var(--theme_light--scrollbar);
--theme--scrollbar-border: var(--theme_light--scrollbar-border);
--theme--scrollbar_hover: var(--theme_light--scrollbar_hover);
--theme--card: var(--theme_light--card);
--theme--gallery: var(--theme_light--gallery);
--theme--select_input: var(--theme_light--select_input);
--theme--table-border: var(--theme_light--table-border);
--theme--table-border_row: var(--theme_light--table-border_row);
--theme--table-border_column: var(--theme_light--table-border_column);
--theme--table-border_selected: var(--theme_light--table-border_selected);
--theme--ui-border: var(--theme_light--ui-border);
--theme--interactive_hover: var(--theme_light--interactive_hover);
--theme--interactive_hover-border: var(
--theme_light--interactive_hover-border
);
--theme--button_close: var(--theme_light--button_close);
--theme--button_close-fill: var(--theme_light--button_close-fill);
--theme--selected: var(--theme_light--selected);
--theme--primary: var(--theme_light--primary);
--theme--primary_text: var(--theme_light--primary_text);
--theme--primary_hover: var(--theme_light--primary_hover);
--theme--primary_click: var(--theme_light--primary_click);
--theme--primary_indicator: var(--theme_light--primary_indicator);
--theme--primary_indicator_text: var(--theme_light--primary_indicator_text);
--theme--primary_indicator_hover: var(--theme_light--primary_indicator_hover);
--theme--option-color: var(--theme_light--option-color);
--theme--option-background: var(--theme_light--option-background);
--theme--option_hover-color: var(--theme_light--option_hover-color);
--theme--option_hover-background: var(--theme_light--option_hover-background);
--theme--option_active-color: var(--theme_light--option_active-color);
--theme--option_active-background: var(
--theme_light--option_active-background
);
--theme--danger_text: var(--theme_light--danger_text);
--theme--danger_border: var(--theme_light--danger_border);
--theme--divider: var(--theme_light--divider);
--theme--text: var(--theme_light--text);
--theme--text_ui: var(--theme_light--text_ui);
--theme--text_ui_info: var(--theme_light--text_ui_info);
--theme--text_gray: var(--theme_light--text_gray);
--theme--text_brown: var(--theme_light--text_brown);
--theme--text_orange: var(--theme_light--text_orange);
--theme--text_yellow: var(--theme_light--text_yellow);
--theme--text_green: var(--theme_light--text_green);
--theme--text_blue: var(--theme_light--text_blue);
--theme--text_purple: var(--theme_light--text_purple);
--theme--text_pink: var(--theme_light--text_pink);
--theme--text_red: var(--theme_light--text_red);
--theme--select-text: var(--theme_light--select-text);
--theme--bg-text: var(--theme_light--bg-text);
--theme--bg_gray: var(--theme_light--bg_gray);
--theme--bg_gray-text: var(--theme_light--bg_gray-text);
--theme--bg_brown: var(--theme_light--bg_brown);
--theme--bg_brown-text: var(--theme_light--bg_brown-text);
--theme--bg_orange: var(--theme_light--bg_orange);
--theme--bg_orange-text: var(--theme_light--bg_orange-text);
--theme--bg_yellow: var(--theme_light--bg_yellow);
--theme--bg_yellow-text: var(--theme_light--bg_yellow-text);
--theme--bg_green: var(--theme_light--bg_green);
--theme--bg_green-text: var(--theme_light--bg_green-text);
--theme--bg_blue: var(--theme_light--bg_blue);
--theme--bg_blue-text: var(--theme_light--bg_blue-text);
--theme--bg_purple: var(--theme_light--bg_purple);
--theme--bg_purple-text: var(--theme_light--bg_purple-text);
--theme--bg_pink: var(--theme_light--bg_pink);
--theme--bg_pink-text: var(--theme_light--bg_pink-text);
--theme--bg_red: var(--theme_light--bg_red);
--theme--bg_red-text: var(--theme_light--bg_red-text);
--theme--line-text: var(--theme_light--line-text);
--theme--line_gray: var(--theme_light--line_gray);
--theme--line_gray-text: var(--theme_light--line_gray-text);
--theme--line_brown: var(--theme_light--line_brown);
--theme--line_brown-text: var(--theme_light--line_brown-text);
--theme--line_orange: var(--theme_light--line_orange);
--theme--line_orange-text: var(--theme_light--line_orange-text);
--theme--line_yellow: var(--theme_light--line_yellow);
--theme--line_yellow-text: var(--theme_light--line_yellow-text);
--theme--line_green: var(--theme_light--line_green);
--theme--line_green-text: var(--theme_light--line_green-text);
--theme--line_blue: var(--theme_light--line_blue);
--theme--line_blue-text: var(--theme_light--line_blue-text);
--theme--line_purple: var(--theme_light--line_purple);
--theme--line_purple-text: var(--theme_light--line_purple-text);
--theme--line_pink: var(--theme_light--line_pink);
--theme--line_pink-text: var(--theme_light--line_pink-text);
--theme--line_red: var(--theme_light--line_red);
--theme--line_red-text: var(--theme_light--line_red-text);
--theme--select_gray: var(--theme_light--select_gray);
--theme--select_gray-text: var(--theme_light--select_gray-text);
--theme--select_brown: var(--theme_light--select_brown);
--theme--select_brown-text: var(--theme_light--select_brown-text);
--theme--select_orange: var(--theme_light--select_orange);
--theme--select_orange-text: var(--theme_light--select_orange-text);
--theme--select_yellow: var(--theme_light--select_yellow);
--theme--select_yellow-text: var(--theme_light--select_yellow-text);
--theme--select_green: var(--theme_light--select_green);
--theme--select_green-text: var(--theme_light--select_green-text);
--theme--select_blue: var(--theme_light--select_blue);
--theme--select_blue-text: var(--theme_light--select_blue-text);
--theme--select_purple: var(--theme_light--select_purple);
--theme--select_purple-text: var(--theme_light--select_purple-text);
--theme--select_pink: var(--theme_light--select_pink);
--theme--select_pink-text: var(--theme_light--select_pink-text);
--theme--select_red: var(--theme_light--select_red);
--theme--select_red-text: var(--theme_light--select_red-text);
--theme--callout-text: var(--theme_light--callout-text);
--theme--callout_gray: var(--theme_light--callout_gray);
--theme--callout_gray-text: var(--theme_light--callout_gray-text);
--theme--callout_brown: var(--theme_light--callout_brown);
--theme--callout_brown-text: var(--theme_light--callout_brown-text);
--theme--callout_orange: var(--theme_light--callout_orange);
--theme--callout_orange-text: var(--theme_light--callout_orange-text);
--theme--callout_yellow: var(--theme_light--callout_yellow);
--theme--callout_yellow-text: var(--theme_light--callout_yellow-text);
--theme--callout_green: var(--theme_light--callout_green);
--theme--callout_green-text: var(--theme_light--callout_green-text);
--theme--callout_blue: var(--theme_light--callout_blue);
--theme--callout_blue-text: var(--theme_light--callout_blue-text);
--theme--callout_purple: var(--theme_light--callout_purple);
--theme--callout_purple-text: var(--theme_light--callout_purple-text);
--theme--callout_pink: var(--theme_light--callout_pink);
--theme--callout_pink-text: var(--theme_light--callout_pink-text);
--theme--callout_red: var(--theme_light--callout_red);
--theme--callout_red-text: var(--theme_light--callout_red-text);
--theme--code_inline-text: var(--theme_light--code_inline-text);
--theme--code_inline-background: var(--theme_light--code_inline-background);
--theme--code-text: var(--theme_light--code-text);
--theme--code-background: var(--theme_light--code-background);
--theme--code_function: var(--theme_light--code_function);
--theme--code_parameter: var(--theme_light--code_parameter);
--theme--code_keyword: var(--theme_light--code_keyword);
--theme--code_constant: var(--theme_light--code_constant);
--theme--code_tag: var(--theme_light--code_tag);
--theme--code_operator: var(--theme_light--code_operator);
--theme--code_important: var(--theme_light--code_important);
--theme--code_regex: var(--theme_light--code_regex);
--theme--code_property: var(--theme_light--code_property);
--theme--code_builtin: var(--theme_light--code_builtin);
--theme--code_class-name: var(--theme_light--code_class-name);
--theme--code_attr-name: var(--theme_light--code_attr-name);
--theme--code_attr-value: var(--theme_light--code_attr-value);
--theme--code_selector: var(--theme_light--code_selector);
--theme--code_id: var(--theme_light--code_id);
--theme--code_class: var(--theme_light--code_class);
--theme--code_pseudo-element: var(--theme_light--code_pseudo-element);
--theme--code_pseudo-class: var(--theme_light--code_pseudo-class);
--theme--code_attribute: var(--theme_light--code_attribute);
--theme--code_value: var(--theme_light--code_value);
--theme--code_unit: var(--theme_light--code_unit);
--theme--code_comment: var(--theme_light--code_comment);
--theme--code_punctuation: var(--theme_light--code_punctuation);
--theme--code_annotation: var(--theme_light--code_annotation);
--theme--code_decorator: var(--theme_light--code_decorator);
--theme--code_doctype: var(--theme_light--code_doctype);
--theme--code_number: var(--theme_light--code_number);
--theme--code_string: var(--theme_light--code_string);
--theme--code_boolean: var(--theme_light--code_boolean);
}

View File

@ -1,65 +0,0 @@
/*
* custom inserts
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
const { createElement } = require('../../pkg/helpers.js');
module.exports = {
id: 'b4b0aced-2059-43bf-8d1d-ccd757ee5ebb',
tags: ['extension'],
name: 'custom inserts',
desc: `link files for small client-side tweaks. (not sure how to do something? check out the
[tweaks](https://github.com/notion-enhancer/notion-enhancer/blob/master/TWEAKS.md) collection.)`,
version: '0.1.3',
author: 'dragonwocky',
options: [
{
key: 'css',
label: 'css insert',
type: 'file',
extensions: ['css'],
},
{
key: 'js',
label: 'client-side js insert',
type: 'file',
extensions: ['js'],
},
],
hacks: {
'renderer/preload.js'(store, __exports) {
const fs = require('fs-extra');
document.addEventListener('readystatechange', (event) => {
if (document.readyState !== 'complete') return false;
if (store().css) {
try {
document
.querySelector('head')
.appendChild(
createElement(
`<style type="text/css">${fs.readFileSync(
store().css
)}</style>`
)
);
} catch (err) {
console.warn('<custom-inserts> invalid css file... unsetting.');
store().css = '';
}
}
if (store().js) {
try {
require(store().js);
} catch (err) {
console.warn('<custom-inserts> invalid js file... unsetting.');
store().js = '';
}
}
});
},
},
};

View File

@ -1,12 +0,0 @@
/*
* panel sites
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 CloudHill
* under the MIT license
*/
.panel-site {
border: none;
flex: 1;
background: white;
}

View File

@ -1,28 +0,0 @@
/*
* panel sites
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 CloudHill
* under the MIT license
*/
'use strict';
module.exports = {
id: '0d541743-eb2c-4d77-83a8-3b2f5e8e5dff',
tags: ['extension', 'panel'],
name: 'panel sites',
desc: 'embed sites on the site panel.',
version: '1.0.0',
author: 'CloudHill',
options: [
{
key: 'sites',
label: 'list of sites',
type: 'file',
extensions: ['json'],
},
],
panel: {
js: 'panel.js'
}
};

View File

@ -1,45 +0,0 @@
/*
* panel sites
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 CloudHill
* under the MIT license
*/
const electron = require('electron')
module.exports = (store) => {
let iframe;
const mainWindow = electron.remote.getCurrentWindow();
const originalUserAgent = mainWindow.webContents.getUserAgent();
const mobileUserAgent =
'Mozilla/5.0 (Linux; Android 7.0; SM-G930V Build/NRD90M) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.125 Mobile Safari/537.36'
// bypass x-frame-options
mainWindow.webContents.session.webRequest.onHeadersReceived((details, callback) => {
const responseHeaders = Object.entries(details.responseHeaders)
.filter( h => !/x-frame-options/i.test(h[0]) );
callback({
responseHeaders: Object.fromEntries(responseHeaders)
});
});
// handle opening mobile sites
function setUserAgent(userAgent) {
mainWindow.webContents.session.webRequest.onBeforeSendHeaders((details, callback) => {
details.requestHeaders['User-Agent'] = userAgent;
callback({ cancel: false, requestHeaders: details.requestHeaders });
});
}
return {
onLoad() {
iframe = document.querySelector('.panel-site');
if (iframe.hasAttribute('mobile-user-agent'))
setUserAgent(mobileUserAgent);
},
onSwitch() {
if (iframe.hasAttribute('mobile-user-agent'))
setUserAgent(originalUserAgent);
}
}
}

View File

@ -1,219 +0,0 @@
/*
* side panel
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 CloudHill
* under the MIT license
*/
.notion-frame {
transition: padding-right 300ms ease-in-out;
}
.enhancer-panel--container {
flex-grow: 0;
flex-shrink: 0;
position: absolute;
top: 0;
bottom: 0;
right: 0;
z-index: 99;
height: 100vh;
background: var(--theme--sidebar);
color: var(--theme--text_ui);
font-weight: 500;
cursor: default;
transition: box-shadow 300ms ease-in, width 300ms ease-in-out;
}
#enhancer-panel {
display: flex;
flex-direction: column;
position: relative;
pointer-events: auto;
background: var(--theme--sidebar);
cursor: auto;
max-height: 100%;
transition: transform 300ms ease-in-out,
opacity 300ms ease-in-out,
right 300ms ease-in-out;
}
#enhancer-panel[data-locked="false"] {
max-height: calc(100vh - 120px);
box-shadow: var(--theme--box-shadow_strong) !important;
}
#enhancer-panel[data-full-height="true"] {
height: 100%;
}
#enhancer-panel[data-locked="false"][data-full-height="true"] {
height: calc(100vh - 120px);
}
.enhancer-panel--header {
flex-grow: 0;
flex-shrink: 0;
display: flex;
align-items: center;
height: 45px;
width: 100%;
color: var(--theme--text);
font-size: 14px;
padding: 2px 14px;
overflow: hidden;
user-select: none;
cursor: pointer;
transition: color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}
.enhancer-panel--header:hover {
background: var(--theme--interactive_hover);
}
.enhancer-panel--icon {
flex-grow: 0;
flex-shrink: 0;
border-radius: 3px;
width: 22px;
height: 22px;
margin-right: 8px;
display: flex;
align-items: center;
justify-content: center;
}
.enhancer-panel--icon svg {
width: 100%;
height: 100%;
}
.enhancer-panel--title {
margin-right: 6px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
.enhancer-panel--reload-button {
flex-grow: 0;
flex-shrink: 0;
display: flex;
align-items: center;
justify-content: center;
width: 24px;
height: 24px;
padding: 6px;
margin-right: 6px;
border-radius: 3px;
transition: background 20ms ease-in;
}
.enhancer-panel--reload-button:hover {
background: var(--theme--main)
}
.enhancer-panel--switcher-icon {
flex-grow: 0;
flex-shrink: 0;
width: 12px;
height: 12px;
fill: var(--theme--text_ui);
}
.enhancer-panel--reload-button svg,
.enhancer-panel--switcher-icon svg {
width: 100%;
height: 100%;
display: block;
fill: var(--theme--text_ui_info);
}
.enhancer-panel--toggle {
flex-grow: 0;
flex-shrink: 0;
position: relative;
display: flex;
align-items: center;
justify-content: center;
margin-left: auto;
height: 24px;
width: 24px;
border-radius: 3px;
cursor: pointer;
opacity: 0;
transition: background 20ms ease-in, opacity 300ms ease-in;
}
#enhancer-panel:hover .enhancer-panel--toggle {
opacity: 1;
}
.enhancer-panel--toggle:hover {
background: var(--theme--interactive_hover);
}
.enhancer-panel--toggle svg {
width: 14px;
height: 14px;
fill: var(--theme--text_ui);
transition: transform 400ms ease-in;
fill: var(--theme--text_ui_info);
}
#enhancer-panel[data-locked="false"] .enhancer-panel--toggle svg {
transform: rotateZ(-180deg);
}
#enhancer-panel--content {
flex: 1;
width: 100%;
color: var(--theme--text);
font-size: var(--theme--font_body-size);
display: flex;
flex-direction: column;
position: relative;
min-height: 0;
}
.enhancer-panel--resize {
position: absolute;
top: 0px;
left: 0px;
height: 100vh;
width: 0px;
z-index: 1;
}
#enhancer-panel[data-locked="false"] .enhancer-panel--resize {
height: 100%;
}
.enhancer-panel--resize div {
height: 100%;
width: 6px;
}
.enhancer-panel--overlay-container {
position: fixed;
top: 0;
right: 0;
bottom: 0;
left: 0;
z-index: 999;
overflow: hidden;
}
.enhancer-panel--switcher {
max-width: 320px;
position: relative;
right: 14px;
border-radius: 3px;
padding: 8px 0;
box-shadow: var(--theme--box-shadow_strong);
background: var(--theme--card);
overflow: hidden;
}
.enhancer-panel--switcher-item {
display: flex;
align-items: center;
width: 100%;
padding: 8px 14px;
color: var(--theme--text);
font-size: 14px;
user-select: none;
cursor: pointer;
overflow: hidden;
transition: background 300ms ease;
}
.enhancer-panel--switcher-item:hover,
.enhancer-panel--switcher-item:focus {
background: var(--theme--interactive_hover);
}

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 14 14">
<path d="M7 12.025L8.225 13.25L14 7.125L8.225 1L7 2.225L11.55 7.125L7 12.025ZM0 12.025L1.225 13.25L7 7.125L1.225 1L8.56743e-07 2.225L4.55 7.125L0 12.025Z" />
</svg>

Before

Width:  |  Height:  |  Size: 250 B

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
<path d="M14.66.27l-.81,3.56a8.35,8.35,0,0,1-3.7,16.28,8.35,8.35,0,0,1-6.29-10A8.42,8.42,0,0,1,5,7.39l2.64,2.72L10.05.27l-9.92,2L2.45,4.72a12,12,0,0,0,6.89,19A11.55,11.55,0,0,0,12,24,12,12,0,0,0,14.66.27Z"/>
</svg>

Before

Width:  |  Height:  |  Size: 277 B

View File

@ -1,3 +0,0 @@
<svg xmlns="http://www.w3.org/2000/svg" width="9" height="11" viewBox="-1 -1 9 11">
<path d="M 3.5 0L 3.98809 -0.569442L 3.5 -0.987808L 3.01191 -0.569442L 3.5 0ZM 3.5 9L 3.01191 9.56944L 3.5 9.98781L 3.98809 9.56944L 3.5 9ZM 0.488094 3.56944L 3.98809 0.569442L 3.01191 -0.569442L -0.488094 2.43056L 0.488094 3.56944ZM 3.01191 0.569442L 6.51191 3.56944L 7.48809 2.43056L 3.98809 -0.569442L 3.01191 0.569442ZM -0.488094 6.56944L 3.01191 9.56944L 3.98809 8.43056L 0.488094 5.43056L -0.488094 6.56944ZM 3.98809 9.56944L 7.48809 6.56944L 6.51191 5.43056L 3.01191 8.43056L 3.98809 9.56944Z" />
</svg>

Before

Width:  |  Height:  |  Size: 596 B

View File

@ -1,506 +0,0 @@
/*
* side panel
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (c) 2020 CloudHill
* under the MIT license
*/
'use strict';
const { createElement, getEnhancements } = require('../../pkg/helpers.js'),
path = require('path'),
fs = require('fs-extra');
module.exports = {
id: 'c8b1db83-ee37-45b4-bdb3-a7f3d36113db',
tags: ['extension', 'panel'],
name: 'side panel',
desc: 'adds a side panel to notion.',
version: '1.1.0',
author: 'CloudHill',
hacks: {
'renderer/preload.js'(store, __exports) {
// Load icons
let icons = {};
(async () => {
icons.doubleChevron = await fs.readFile( path.resolve(__dirname, 'icons/double-chevron.svg') );
icons.switcher = await fs.readFile( path.resolve(__dirname, 'icons/switcher.svg') );
icons.reload = await fs.readFile( path.resolve(__dirname, 'icons/reload.svg') );
})();
// Load panel mods
let panelMods =
getEnhancements().loaded.filter(
mod => (mod.panel && (store('mods')[mod.id] || {}).enabled)
);
panelMods.forEach(mod => initMod(mod));
document.addEventListener('readystatechange', (event) => {
if (document.readyState !== 'complete') return false;
if (panelMods.length < 1) return;
const attempt_interval = setInterval(enhance, 500);
function enhance() {
if (!store().width) store().width = 220;
let curPanel = {};
const frame = document.querySelector('.notion-frame');
if (!frame) return;
clearInterval(attempt_interval);
// Initialize panel
const container = createElement(
'<div class="enhancer-panel--container"></div>'
);
const panel = createElement(
`<div id="enhancer-panel"></div>`
);
frame.after(container);
container.appendChild(panel);
// Panel contents
const header = createElement(`
<div class="enhancer-panel--header">
<div class="enhancer-panel--icon"></div>
<div class="enhancer-panel--title"></div>
</div>
`);
const toggle = createElement(
`<div class="enhancer-panel--toggle">${icons.doubleChevron}</div>`
);
const content = createElement(
'<div id="enhancer-panel--content"></div>'
);
const resize = createElement(`
<div class="enhancer-panel--resize">
<div style="cursor: col-resize;"></div>
</div>
`);
panel.append(header, content, resize);
// Add switcher if there is more than one panel mods
if (panelMods.length > 1) {
header.addEventListener('click', renderSwitcher);
const switcherIcon = createElement(
`<div class="enhancer-panel--switcher-icon">${icons.switcher}</div>`
)
header.appendChild(switcherIcon);
} else {
header.addEventListener('click', togglePanel);
}
header.appendChild(toggle);
toggle.addEventListener('click', togglePanel);
// Keybind
document.addEventListener('keyup', e => {
const hotkey = {
code: 'Backslash',
ctrlKey: true,
shiftKey: true,
metaKey: false,
altKey: false,
};
for (let prop in hotkey)
if (hotkey[prop] !== e[prop]) return;
togglePanel();
});
// Restore lock state
if (store().locked === 'false') unlockPanel(false);
else lockPanel();
enableResize();
// Attempt to load last opened mod
let loaded = false;
if (store().last_open) {
panelMods.forEach(mod => {
if (mod.id === store().last_open) {
loadContent(mod);
loaded = true;
}
});
}
if (!loaded) loadContent(panelMods[0]);
function loadContent(mod) {
if (curPanel.js && curPanel.js.onSwitch) curPanel.js.onSwitch();
curPanel = mod.panel;
store().last_open = mod.id;
panel.querySelector('.enhancer-panel--title').innerHTML = mod.panel.name || mod.name;
// Reload button
let reloadButton = panel.querySelector('.enhancer-panel--reload-button');
if (reloadButton) reloadButton.remove();
if (mod.panel.reload) {
reloadButton = createElement(
`<div class="enhancer-panel--reload-button">${icons.reload}</div>`
)
reloadButton.addEventListener('click', e => {
e.stopPropagation();
loadContent(mod);
})
panel.querySelector('.enhancer-panel--title').after(reloadButton);
}
panel.querySelector('.enhancer-panel--icon').innerHTML = mod.panel.icon;
document.getElementById('enhancer-panel--content').innerHTML = mod.panel.html;
panel.dataset.fullHeight = mod.panel.fullHeight || false;
if (curPanel.js && curPanel.js.onLoad)
curPanel.js.onLoad();
}
function unlockPanel(animate) {
panel.dataset.locked = 'false';
setPanelWidth(store().width);
if (animate) {
panel.animate(
[
{ opacity: 1, transform: 'none' },
{ opacity: 1, transform: 'translateY(60px)', offset: 0.4},
{ opacity: 0, transform: `translateX(${store().width - 30}px) translateY(60px)`},
],
{ duration: 600, easing: 'ease-out' }
).onfinish = () => {
panel.addEventListener('mouseover', showPanel);
panel.addEventListener('mouseleave', hidePanel);
}
} else {
panel.addEventListener('mouseover', showPanel);
panel.addEventListener('mouseleave', hidePanel);
}
hidePanel();
if (curPanel.js && curPanel.js.onUnlock) {
curPanel.js.onUnlock();
}
}
function lockPanel() {
panel.dataset.locked = 'true';
setPanelWidth(store().width);
// Reset animation styles
panel.style.opacity = '';
panel.style.transform = '';
// Hover event listeners
panel.removeEventListener('mouseover', showPanel);
panel.removeEventListener('mouseleave', hidePanel);
if (curPanel.js && curPanel.js.onLock) {
curPanel.js.onLock();
}
}
function togglePanel(e) {
if (e) e.stopPropagation();
if (isLocked()) unlockPanel(true);
else lockPanel();
store().locked = panel.dataset.locked;
}
function showPanel() {
if (!isLocked()) {
panel.style.opacity = 1;
panel.style.transform = 'translateY(60px)';
}
}
function hidePanel() {
if (!isLocked()) {
panel.style.opacity = 0;
panel.style.transform = `translateX(${store().width - 30}px) translateY(60px)`;
}
}
function renderSwitcherItem(mod) {
if (mod.panel) {
const item = createElement(
`<div class="enhancer-panel--switcher-item" tabindex="0">
<div class="enhancer-panel--icon">${mod.panel.icon}</div>
<div class="enhancer-panel--title">${mod.panel.name || mod.name}</div>
</div>`
);
item.addEventListener('click', () => loadContent(mod));
return item;
}
}
function renderSwitcher() {
if (document.querySelector('.enhancer-panel--overlay-container')) return;
// Layer to close switcher
const overlayContainer = createElement(
'<div class="enhancer-panel--overlay-container"></div>'
);
overlayContainer.addEventListener('click', hideSwitcher)
document
.querySelector('.notion-app-inner')
.appendChild(overlayContainer);
// Position switcher below header
const rect = panel.querySelector('.enhancer-panel--header').getBoundingClientRect();
const div = createElement(`
<div style="position: fixed; top: ${rect.top}px; left: ${rect.left}px; width: ${rect.width}px; height: ${rect.height}px ">
<div style="position: relative; top: 100%; pointer-events: auto;"></div>
</div>
`);
// Render switcher
const switcher = createElement(
'<div class="enhancer-panel--switcher"></div>'
);
panelMods.forEach(mod =>
switcher.append(renderSwitcherItem(mod))
);
overlayContainer.appendChild(div);
div.firstElementChild.appendChild(switcher);
switcher.firstElementChild.focus();
// Fade in
switcher.animate(
[ {opacity: 0}, {opacity: 1} ],
{ duration: 200 }
);
// Prevent panel from closing if unlocked
panel.removeEventListener('mouseleave', hidePanel);
// Escape key listener
document.addEventListener('keydown', switcherKeyEvent);
}
function hideSwitcher() {
const overlayContainer = document.querySelector('.enhancer-panel--overlay-container');
overlayContainer.removeEventListener('click', hideSwitcher);
document.removeEventListener('keydown', switcherKeyEvent);
// Fade out
document.querySelector('.enhancer-panel--switcher').animate(
[ {opacity: 1}, {opacity: 0} ],
{ duration: 200 }
).onfinish = () => overlayContainer.remove();
if (!isLocked()) panel.addEventListener('mouseleave', hidePanel);
}
function setPanelWidth(width) {
store().width = width;
panel.style.width = width + 'px';
if (isLocked()) {
container.style.width = width + 'px';
frame.style.paddingRight = width + 'px';
panel.style.right = 0;
} else {
container.style.width = 0;
frame.style.paddingRight = 0;
panel.style.right = width + 'px';
}
}
function enableResize() {
const handle = panel.querySelector('.enhancer-panel--resize div');
handle.addEventListener('mousedown', initDrag);
let startX, startWidth;
const div = createElement(
'<div style="position: absolute; top: 0; left: 0; right: 0; bottom: 0; z-index: 99;"></div>'
);
function initDrag(e) {
startX = e.clientX;
startWidth = store().width;
panel.appendChild(div);
// Set transitions
container.style.transition = 'width 50ms ease-in';
panel.style.transition = 'width 50ms ease-in, right 50ms ease-in';
frame.style.transition = 'padding-right 50ms ease-in';
handle.style.cursor = '';
// Prevent panel from closing if unlocked
panel.removeEventListener('mouseleave', hidePanel);
document.body.addEventListener('mousemove', drag);
document.body.addEventListener('mouseup', stopDrag);
}
function drag(e) {
e.preventDefault();
let width = startWidth + (startX - e.clientX);
if (width < 190) width = 190;
if (width > 480) width = 480;
setPanelWidth(width);
if (curPanel.js && curPanel.js.onResize) {
curPanel.js.onResize();
}
}
function stopDrag() {
handle.style.cursor = 'col-resize';
panel.removeChild(div);
// Reset transitions
container.style.transition =
panel.style.transition =
frame.style.transition = '';
if (!isLocked()) panel.addEventListener('mouseleave', hidePanel);
document.body.removeEventListener('mousemove', drag);
document.body.removeEventListener('mouseup', stopDrag);
}
}
function isLocked() {
if (panel.dataset.locked === 'true') return true;
else return false;
}
function switcherKeyEvent(e) {
e.stopPropagation();
if (e.key === 'Escape') return hideSwitcher();
const currentFocus = document.activeElement;
if ([' ', 'Enter'].includes(e.key)) return currentFocus.click();
const focusNext = () => {
const nextEl = currentFocus.nextElementSibling;
if (nextEl) nextEl.focus();
else currentFocus.parentElement.firstElementChild.focus();
}
const focusPrevious = () => {
const prevEl = currentFocus.previousElementSibling;
if (prevEl) prevEl.focus();
else currentFocus.parentElement.lastElementChild.focus();
}
if (e.key === 'ArrowUp') focusPrevious();
else if (e.key === 'ArrowDown') focusNext();
else if (e.key === 'Tab') {
if (e.shiftKey) focusPrevious();
else focusNext();
e.preventDefault();
}
}
}
});
// INITIALIZATION FUNCTIONS
async function initMod(mod) {
// load panel sites
if (mod.id === '0d541743-eb2c-4d77-83a8-3b2f5e8e5dff') {
panelMods = panelMods.filter(panelMod => panelMod !== mod);
return panelMods.push(...initPanelSites(mod));
}
try {
if (typeof mod.panel === 'object') {
// html
mod.panel.html = await fs.readFile(
path.resolve(__dirname, `../${mod.dir}/${mod.panel.html}`)
);
// name
if (!mod.panel.name) mod.panel.name = mod.name;
// icon
if (mod.panel.icon) {
const iconPath = path.resolve(__dirname, `../${mod.dir}/${mod.panel.icon}`);
if (await fs.pathExists(iconPath))
mod.panel.icon = await fs.readFile(iconPath);
} else {
mod.panel.icon = mod.panel.name[0];
}
// js
if (mod.panel.js) {
const jsPath = `../${mod.dir}/${mod.panel.js}`;
if (await fs.pathExists(path.resolve(__dirname, jsPath))) {
mod.panel.js = require(jsPath)(loadStore(mod), __exports);
}
}
} else if (typeof mod.panel === 'string') {
mod.panel.icon = mod.name[0];
mod.panel.html = await fs.readFile(
path.resolve(__dirname, `../${mod.dir}/${mod.panel}`)
);
} else throw Error;
} catch (err) {
console.log('invalid panel mod: ' + mod.name);
panelMods = panelMods.filter(panelMod => panelMod !== mod);
}
}
function initPanelSites(mod) {
let panelSites = [];
const sitesPath = store(mod.id).sites;
if (sitesPath) {
try {
const sites = require(sitesPath);
const invalid = false;
const sitePanelJs = require('../panel-sites/panel.js')(loadStore(mod), __exports);
const frameUrl = function(url, mobile) {
if (!/(^https?:\/\/)/.test(url)) url = 'https://' + url;
return `<iframe src=${url} class="panel-site" ${mobile ? 'mobile-user-agent' : ''}></iframe>`;
}
sites.forEach(site => {
if (site.url && site.name) {
// get url and icon
const iframe = frameUrl(site.url, site.mobile);
const icon = `<img style="width: 100%; height: 100%;"
src="${site.icon || `https://www.google.com/s2/favicons?domain=${site.url}`}" />`;
const panelMod = {
id: `${mod.id}-${site.url}`,
panel: {
name: site.name,
html: iframe,
icon: icon,
js: sitePanelJs,
fullHeight: true,
reload: true,
},
}
panelSites.push(panelMod);
} else invalid = true;
});
if (invalid) throw Error;
}
catch (err) {
console.log('panel site error');
}
}
return panelSites;
}
function loadStore(mod) {
return (...args) => {
if (!args.length) return store(mod.id, mod.defaults);
if (args.length === 1 && typeof args[0] === 'object')
return store(mod.id, { ...mod.defaults, ...args[0] });
const other_mod = modules.find((m) => m.id === args[0]);
return store(args[0], {
...(other_mod ? other_mod.defaults : {}),
...(args[1] || {})
})
}
}
},
},
};

View File

@ -1,49 +0,0 @@
/*
* tabs
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
// this is just a pseudo mod to "separate" the options
// from the core module - the core still handles actually
// making it work.
module.exports = {
id: 'e1692c29-475e-437b-b7ff-3eee872e1a42',
tags: ['core', 'extension'],
name: 'tabs',
desc: 'have multiple notion pages open in a single window.',
version: '0.1.0',
author: 'dragonwocky',
options: [
{
key: 'select_modifier',
label:
'tab select modifier (key+1, +2, +3, ... +9 and key+left/right arrows):',
type: 'select',
value: [
'Alt',
'Command',
'Control',
'Super',
'Alt+Shift',
'Command+Shift',
'Control+Shift',
'Super+Shift',
],
},
{
key: 'new_tab',
label: 'new tab keybinding:',
type: 'input',
value: 'CommandOrControl+T',
},
{
key: 'close_tab',
label: 'close tab keybinding:',
type: 'input',
value: 'CommandOrControl+W',
},
],
};

View File

@ -1,62 +0,0 @@
/*
* tweaks
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
[data-tweaks*='[responsive_breakpoint]']
.notion-column_list-block
[style='display: flex;']
> div {
width: 100% !important;
}
[data-tweaks*='[responsive_breakpoint]']
.notion-column_list-block
[style='display: flex;'] {
flex-direction: column !important;
}
[data-tweaks*='[responsive_breakpoint]'] .notion-app-inner {
--theme_dark--page_normal-width: 100%;
--theme_dark--page-padding: calc(48px + env(safe-area-inset-left));
--theme_light--page_normal-width: 100%;
--theme_light--page-padding: calc(48px + env(safe-area-inset-left));
}
[data-tweaks*='[snappy_transitions]'] * {
animation-duration: 0s !important;
transition-duration: 0s !important;
}
[data-tweaks*='[snappy_transitions]'] .notion-selectable-halo {
opacity: 1 !important;
}
[data-tweaks*='[hide_help]'] .notion-help-button {
display: none !important;
}
[data-tweaks*='[thicker_bold]']
.notion-page-content
span[style*='font-weight:600'] {
font-weight: 700 !important;
}
[data-tweaks*='[spaced_lines]'] {
--theme_dark--text-block_line-height: 1.65;
--theme_dark--text-block_margin-top: 0.75em;
--theme_light--text-block_line-height: 1.65;
--theme_light--text-block_margin-top: 0.75em;
}
[data-tweaks*='[condensed_bullets]']
.notion-selectable.notion-bulleted_list-block {
line-height: 1.1 !important;
margin-top: -1.5px !important;
margin-bottom: -1.5px !important;
}
[data-tweaks*='[scroll_db_toolbars]'] .notion-collection_view-block > [style*=" height: 42px"] {
overflow-x: auto !important;
}
[data-tweaks*='[scroll_db_toolbars]'] .notion-collection_view-block > [style*=" height: 42px"]::-webkit-scrollbar {
display: none;
}

View File

@ -1,120 +0,0 @@
/*
* tweaks
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* under the MIT license
*/
'use strict';
module.exports = {
id: 'cf8a7b27-5a4c-4d45-a4cb-1d2bbc9e9014',
alwaysActive: true,
tags: ['core', 'extension'],
name: 'tweaks',
desc: 'common style/layout changes.',
version: '0.1.0',
author: 'dragonwocky',
options: [
{
key: 'dragarea_height',
label: 'height of frameless dragarea:',
desc: `the rectangle added at the top of a window in "integrated titlebar" mode,\
used to drag/move the window.`,
type: 'input',
value: 15,
platformOverwrite: {
darwin: 0,
},
},
{
key: 'responsive_breakpoint',
label: 'width to wrap columns at:',
desc: `the size in pixels below which in-page columns are resized to appear\
full width so content isn't squished.`,
type: 'input',
value: 600,
},
{
key: 'smooth_scrollbars',
label: 'integrated scrollbars',
desc:
"use scrollbars that fit better into notion's ui instead of the default chrome ones.",
type: 'toggle',
value: true,
},
{
key: 'snappy_transitions',
label: 'snappy transitions',
type: 'toggle',
value: false,
},
{
key: 'thicker_bold',
label: 'thicker bold text',
type: 'toggle',
value: true,
},
{
key: 'spaced_lines',
label: 'more readable line spacing',
type: 'toggle',
value: false,
},
{
key: 'hide_help',
label: 'hide help button',
type: 'toggle',
value: false,
},
{
key: 'condensed_bullets',
label: 'condense bullet points',
desc:
'makes bullet point blocks closer together and have tighter line spacing',
type: 'toggle',
value: false,
},
{
key: 'scroll_db_toolbars',
label: 'scroll database toolbars',
desc:
'allows scrolling database toolbars horizontally if\
part of the toolbar is hidden (hold shift while scrolling)',
type: 'toggle',
value: true,
},
],
hacks: {
'renderer/preload.js': (store, __exports) => {
document.addEventListener('readystatechange', (event) => {
if (document.readyState !== 'complete') return false;
document.body.dataset.tweaks = [
'smooth_scrollbars',
'snappy_transitions',
'thicker_bold',
'spaced_lines',
'hide_help',
'condensed_bullets',
'scroll_db_toolbars',
]
.filter((tweak) => store()[tweak])
.map((tweak) => `[${tweak}]`)
.join('');
document.documentElement.style.setProperty(
'--configured--dragarea_height',
`${store().dragarea_height + 2}px`
);
const addResponsiveBreakpoint = () => {
document.body.dataset.tweaks = document.body.dataset.tweaks.replace(
/\[responsive_breakpoint\]/g,
''
);
if (window.outerWidth <= store().responsive_breakpoint)
document.body.dataset.tweaks += '[responsive_breakpoint]';
};
window.addEventListener('resize', addResponsiveBreakpoint);
addResponsiveBreakpoint();
});
},
},
};

View File

@ -3,22 +3,22 @@
"@types/glob@^7.1.1":
version "7.1.3"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.1.3.tgz#e6ba80f36b7daad2c685acd9266382e68985c183"
integrity sha512-SEYeGAIQIQX8NN6LDKprLjbrd5dARM5EXsd8GI/A5l0apYI1fGMWgPHSe4ZKL4eozlAyI+doUE9XbYS4xCkQ1w==
version "7.2.0"
resolved "https://registry.yarnpkg.com/@types/glob/-/glob-7.2.0.tgz#bc1b5bf3aa92f25bd5dd39f35c57361bdce5b2eb"
integrity sha512-ZUxbzKl0IfJILTS6t7ip5fQQM/J3TJYubDm3nMbgubNNYS62eXeUpoLUC8/7fJNiFYHTrGPQn7hspDUzIHX3UA==
dependencies:
"@types/minimatch" "*"
"@types/node" "*"
"@types/minimatch@*":
version "3.0.3"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.3.tgz#3dca0e3f33b200fc7d1139c0cd96c1268cadfd9d"
integrity sha512-tHq6qdbT9U1IRSGf14CL0pUlULksvY9OZ+5eEgl1N7t+OA3tGvNpxJCzuKQlsNgCVwbAs670L1vcVQi8j9HjnA==
version "3.0.5"
resolved "https://registry.yarnpkg.com/@types/minimatch/-/minimatch-3.0.5.tgz#1001cc5e6a3704b83c236027e77f2f58ea010f40"
integrity sha512-Klz949h02Gz2uZCMGwDUSDS1YBlTdDDgbWHi+81l29tQALUtvz4rAYi5uoVhE5Lagoq6DeqAUlbrHvW/mXDgdQ==
"@types/node@*":
version "14.14.14"
resolved "https://registry.yarnpkg.com/@types/node/-/node-14.14.14.tgz#f7fd5f3cc8521301119f63910f0fb965c7d761ae"
integrity sha512-UHnOPWVWV1z+VV8k6L1HhG7UbGBgIdghqF3l9Ny9ApPghbjICXkUJSd/b9gOgQfjM1r+37cipdw/HJ3F6ICEnQ==
version "16.11.6"
resolved "https://registry.yarnpkg.com/@types/node/-/node-16.11.6.tgz#6bef7a2a0ad684cf6e90fcfe31cecabd9ce0a3ae"
integrity sha512-ua7PgUoeQFjmWPcoo9khiPum3Pd60k4/2ZGXt18sm2Slk0W0xZTqt5Y0Ny1NyBiN1EVQ/+FaF9NcY4Qe6rwk5w==
ansi-styles@^4.1.0:
version "4.3.0"
@ -27,10 +27,10 @@ ansi-styles@^4.1.0:
dependencies:
color-convert "^2.0.1"
asar@^3.0.3:
version "3.0.3"
resolved "https://registry.yarnpkg.com/asar/-/asar-3.0.3.tgz#1fef03c2d6d2de0cbad138788e4f7ae03b129c7b"
integrity sha512-k7zd+KoR+n8pl71PvgElcoKHrVNiSXtw7odKbyNpmgKe7EGRF9Pnu3uLOukD37EvavKwVFxOUpqXTIZC5B5Pmw==
asar@^3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/asar/-/asar-3.1.0.tgz#70b0509449fe3daccc63beb4d3c7d2e24d3c6473"
integrity sha512-vyxPxP5arcAqN4F/ebHd/HhwnAiZtwhglvdmc7BR2f0ywbVNTOpSeyhLDbGXtE/y58hv1oC75TaNIXutnsOZsQ==
dependencies:
chromium-pickle-js "^0.2.0"
commander "^5.0.0"
@ -40,9 +40,9 @@ asar@^3.0.3:
"@types/glob" "^7.1.1"
balanced-match@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.0.tgz#89b4d199ab2bee49de164ea02b89ce462d71b767"
integrity sha1-ibTRmasr7kneFk6gK4nORi1xt2c=
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
brace-expansion@^1.1.7:
version "1.1.11"
@ -52,10 +52,10 @@ brace-expansion@^1.1.7:
balanced-match "^1.0.0"
concat-map "0.0.1"
chalk@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.0.tgz#4e14870a618d9e2edd97dd8345fd9d9dc315646a"
integrity sha512-qwx12AxXe2Q5xQ43Ac//I6v5aXTipYrSESdOgzrN+9XjgEpyjpKuvSGaN4qE93f7TQTlerQQ8S+EQ0EyDoVL1A==
chalk@^4.1.2:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
@ -93,9 +93,9 @@ fs.realpath@^1.0.0:
integrity sha1-FQStJSMVjKpA20onh8sBQRmU6k8=
glob@^7.1.6:
version "7.1.6"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.6.tgz#141f33b81a7c2492e125594307480c46679278a6"
integrity sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"