tweaks: update, add table wrapping & hide '/' for commands

+ other bugfixes
This commit is contained in:
dragonwocky 2021-10-05 00:03:40 +11:00
parent f2928371b6
commit b463b2b7e7
10 changed files with 168 additions and 107 deletions

View File

@ -8,7 +8,6 @@
export default async function (api, db) { export default async function (api, db) {
const { web, notion } = api; const { web, notion } = api;
await web.whenReady();
let _openPage = {}; let _openPage = {};
function getCurrentPage() { function getCurrentPage() {

View File

@ -1,5 +1,5 @@
/* /*
* notion-enhancer core: bypass-preview * notion-enhancer: calendar-scroll
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/) * (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
* (https://notion-enhancer.github.io/) under the MIT license * (https://notion-enhancer.github.io/) under the MIT license
*/ */
@ -60,6 +60,6 @@ export default async function (api, db) {
const toolbar = document.querySelector(toolbarSelector); const toolbar = document.querySelector(toolbarSelector);
if (toolbar) toolbar.insertBefore($scrollButton, toolbar.children[2]); if (toolbar) toolbar.insertBefore($scrollButton, toolbar.children[2]);
}; };
web.addDocumentObserver(insertButton, [toolbarSelector]); web.addDocumentObserver(insertButton, ['.notion-calendar-view']);
insertButton(); insertButton();
} }

View File

@ -27,7 +27,7 @@
"key": "panel.hotkey", "key": "panel.hotkey",
"label": "toggle panel hotkey", "label": "toggle panel hotkey",
"value": "Ctrl+Alt+\\", "value": "Ctrl+Alt+\\",
"tooltip": "opens/closes the side panel in notion - will only work if a mod is making use of it." "tooltip": "**opens/closes the side panel in notion** if a mod that uses it has been enabled"
} }
] ]
} }

View File

@ -46,12 +46,14 @@
.markdown hr { .markdown hr {
border: 0.5px solid var(--theme--ui_divider); border: 0.5px solid var(--theme--ui_divider);
} }
.markdown.markdown-inline a { .markdown-inline a,
.markdown a {
opacity: 0.7; opacity: 0.7;
text-decoration: none; text-decoration: none;
border-bottom: 0.05em solid var(--theme--text_secondary); border-bottom: 0.05em solid var(--theme--text_secondary);
} }
.markdown.markdown-inline a:hover { .markdown-inline a:hover,
.markdown a:hover {
opacity: 0.9; opacity: 0.9;
} }
@ -72,7 +74,8 @@
color: var(--theme--code_plain); color: var(--theme--code_plain);
} }
.markdown pre, .markdown pre,
.markdown.markdown-inline code { .markdown code,
.markdown-inline code {
font-family: var(--theme--font_code); font-family: var(--theme--font_code);
font-size: 0.796875rem; font-size: 0.796875rem;
text-align: left; text-align: left;

View File

@ -194,6 +194,7 @@ const _$modListCache = {},
options: async (mod) => { options: async (mod) => {
const $fragment = document.createDocumentFragment(); const $fragment = document.createDocumentFragment();
for (const opt of mod.options) { for (const opt of mod.options) {
if (!opt.environments.includes(env.name)) continue;
web.render($fragment, await options[opt.type](mod, opt)); web.render($fragment, await options[opt.type](mod, opt));
} }
if (!mod.options.length) { if (!mod.options.length) {

View File

@ -25,7 +25,7 @@
"key": "hotkey", "key": "hotkey",
"label": "toggle focus hotkey", "label": "toggle focus hotkey",
"value": "Ctrl+Alt+E", "value": "Ctrl+Alt+E",
"tooltip": "switches between notion & the enhancer menu" "tooltip": "**switches between notion & the enhancer menu**"
} }
] ]
} }

View File

@ -602,7 +602,6 @@ body,
.notion-collection_view-block .notion-collection_view-block
> [style*='box-shadow: white -3px 0px 0px;'] { > [style*='box-shadow: white -3px 0px 0px;'] {
box-shadow: transparent -3px 0px 0px !important; box-shadow: transparent -3px 0px 0px !important;
margin-left: 20px;
} }
.notion-focusable[role='button'][style*='box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px;'] { .notion-focusable[role='button'][style*='box-shadow: rgba(15, 15, 15, 0.1) 0px 0px 0px 1px;'] {
box-shadow: var(--theme--ui_divider) 0px 0px 0px 1px !important; box-shadow: var(--theme--ui_divider) 0px 0px 0px 1px !important;

View File

@ -5,57 +5,117 @@
* (https://notion-enhancer.github.io/) under the MIT license * (https://notion-enhancer.github.io/) under the MIT license
*/ */
.tweak--snappy_transitions * { .enhancer--tweak-responsive_breakpoint
animation-duration: 0s !important; .notion-column_list-block
transition-duration: 0s !important; [style='display: flex;']
} > div {
.tweak--snappy_transitions .notion-selectable-halo {
opacity: 1 !important;
}
.tweak--hide_help .notion-help-button {
display: none !important;
}
.tweak--thicker_bold .notion-page-content span[style*='font-weight:600'] {
font-weight: 700 !important;
}
.tweak--spaced_lines .notion-page-content .notion-selectable.notion-text-block {
line-height: 1.65 !important;
margin-top: 0.75em !important;
}
.tweak--condensed_bullets .notion-selectable.notion-bulleted_list-block {
margin-top: -1.5px !important;
margin-bottom: -1.5px !important;
}
.tweak--responsive_breakpoint .notion-column_list-block [style='display: flex;'] > div {
width: 100% !important; width: 100% !important;
} }
.tweak--responsive_breakpoint .notion-column_list-block [style='display: flex;'] { .enhancer--tweak-responsive_breakpoint .notion-column_list-block [style='display: flex;'] {
flex-direction: column !important; flex-direction: column !important;
} }
.tweak--responsive_breakpoint .notion-app-inner { .enhancer--tweak-responsive_breakpoint .notion-app-inner {
--theme--page-width: 100%; --theme--page-width: 100%;
--theme--page-padding: calc(48px + env(safe-area-inset-left)); --theme--page-padding: calc(48px + env(safe-area-inset-left));
} }
.tweak--bracketed_links .notion-link-token span { .enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block[style*=' width'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block[style^='width'] {
width: 100% !important;
}
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-left: 50px'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-left: 96px'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-left: 126px'] {
padding-left: 0 !important;
}
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-right: 50px'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-right: 96px'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='padding-right: 126px'] {
padding-right: 0 !important;
}
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='min-width: calc(100% - 192px);'],
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
[style*='min-width: 708px;'] {
min-width: 100% !important;
}
.enhancer--tweak-normalise_table_scroll
.notion-page-content
.notion-collection_view-block
> div {
padding: 0 1px;
}
.enhancer--tweak-snappy_transitions * {
animation-duration: 0s !important;
transition-duration: 0s !important;
}
.enhancer--tweak-snappy_transitions .notion-selectable-halo {
opacity: 1 !important;
}
.enhancer--tweak-hide_help .notion-help-button {
display: none !important;
}
.enhancer--tweak-hide_slash_for_commands [contenteditable]:empty:after {
content: ' ' !important;
}
.enhancer--tweak-thicker_bold .notion-page-content span[style*='font-weight:600'] {
font-weight: 700 !important;
}
.enhancer--tweak-spaced_lines .notion-page-content .notion-selectable.notion-text-block {
line-height: 1.65 !important;
margin-top: 0.75em !important;
}
.enhancer--tweak-condensed_bullets .notion-selectable.notion-bulleted_list-block {
margin-top: -1.5px !important;
margin-bottom: -1.5px !important;
}
.enhancer--tweak-bracketed_links .notion-link-token span {
border-bottom: none !important; border-bottom: none !important;
} }
.tweak--bracketed_links .notion-link-token:before { .enhancer--tweak-bracketed_links .notion-link-token:before {
content: '[['; content: '[[';
opacity: 0.7; opacity: 0.7;
transition: opacity 100ms ease-in; transition: opacity 100ms ease-in;
} }
.tweak--bracketed_links .notion-link-token:after { .enhancer--tweak-bracketed_links .notion-link-token:after {
content: ']]'; content: ']]';
opacity: 0.7; opacity: 0.7;
transition: opacity 100ms ease-in; transition: opacity 100ms ease-in;
} }
.tweak--bracketed_links .notion-link-token:hover::before, .enhancer--tweak-bracketed_links .notion-link-token:hover::before,
.tweak--bracketed_links .notion-link-token:hover::after { .enhancer--tweak-bracketed_links .notion-link-token:hover::after {
opacity: 1; opacity: 1;
} }

View File

@ -6,44 +6,37 @@
'use strict'; 'use strict';
const _id = '5174a483-c88d-4bf8-a95f-35cd330b76e2'; export default async function (api, db) {
import { env, storage, web } from '../../api/_.mjs'; const { web } = api;
web.whenReady().then(async () => { const cssInsert = await db.get(['insert.css']);
const cssInsert = await storage.get(_id, '_file.insert.css'); document.head.append(
if (cssInsert) { web.html`<style id="enhancer--tweak-${cssInsert.filename}">${cssInsert.content}</style>`
document.body.append( );
web.createElement(
web.html`
<style id="${await storage.get(_id, 'insert.css')}@${_id}">${cssInsert}</style>`
)
);
}
if (['linux', 'win32'].includes(env.name)) { const responsiveBreakpoint = await db.get(['tweak.responsive_breakpoint']),
// dragarea_height
}
for (const tweak of [
'snappy_transitions',
'thicker_bold',
'spaced_lines',
'hide_help',
'condensed_bullets',
'bracketed_links',
]) {
if (await storage.get(_id, `tweak.${tweak}`)) {
document.body.classList.add(`tweak--${tweak}`);
}
}
const responsiveBreakpoint = await storage.get(_id, 'tweak.responsive_breakpoint'),
addResponsiveBreakpoint = () => { addResponsiveBreakpoint = () => {
document.body.classList.remove('tweak--responsive_breakpoint'); document.body.classList.remove('enhancer--tweak-responsive_breakpoint');
if (window.innerWidth <= responsiveBreakpoint) { if (window.innerWidth <= responsiveBreakpoint) {
document.body.classList.add('tweak--responsive_breakpoint'); document.body.classList.add('enhancer--tweak-responsive_breakpoint');
} }
}; };
window.addEventListener('resize', addResponsiveBreakpoint); window.addEventListener('resize', addResponsiveBreakpoint);
addResponsiveBreakpoint(); addResponsiveBreakpoint();
});
const tweaks = [
'normalise_table_scroll',
'hide_help',
'hide_slash_for_commands',
'snappy_transitions',
'thicker_bold',
'spaced_lines',
'condensed_bullets',
'bracketed_links',
];
for (const tweak of tweaks) {
if (await db.get([`tweak.${tweak}`])) {
document.body.classList.add(`enhancer--tweak-${tweak}`);
}
}
}

View File

@ -2,7 +2,7 @@
"name": "tweaks", "name": "tweaks",
"id": "5174a483-c88d-4bf8-a95f-35cd330b76e2", "id": "5174a483-c88d-4bf8-a95f-35cd330b76e2",
"version": "0.2.0", "version": "0.2.0",
"description": "common style/layout changes and custom CSS insertion.", "description": "common style/layout changes and custom code insertion. check out the [tweaks page](https://github.com/notion-enhancer/tweaks) for more.",
"tags": ["extension", "customisation"], "tags": ["extension", "customisation"],
"authors": [ "authors": [
{ {
@ -23,61 +23,67 @@
"type": "file", "type": "file",
"key": "insert.css", "key": "insert.css",
"label": "css insert", "label": "css insert",
"tooltip": "**upload a css file that will be applied to the notion client**",
"extensions": [".css"] "extensions": [".css"]
}, },
{ {
"key": "tweak.dragarea_height",
"label": "height of frameless dragarea:",
"tooltip": "the rectangle added at the top of a window in 'integrated titlebar' mode, used to drag/move the window.",
"type": "number", "type": "number",
"value": 15,
"environments": ["linux", "win32"]
},
{
"key": "tweak.responsive_breakpoint", "key": "tweak.responsive_breakpoint",
"label": "responsive columns breakpoint (px)", "label": "responsive columns breakpoint (px)",
"tooltip": "the width in pixels below which in-page columns are resized to appear full-width so content isn't squished.", "tooltip": "the **width in pixels below which in-page columns are resized** to appear full-width to reduce content squishing",
"type": "number",
"value": 600 "value": 600
}, },
{ {
"key": "tweak.snappy_transitions",
"label": "snappy transitions",
"tooltip": "set animation time for all css-driven animations to 0s. may not affect element motion e.g. the sidebar popping out.",
"type": "toggle",
"value": false
},
{
"key": "tweak.hide_help",
"label": "hide help button",
"type": "toggle",
"value": false
},
{
"key": "tweak.thicker_bold",
"label": "thicker bold text",
"type": "toggle", "type": "toggle",
"key": "tweak.normalise_table_scroll",
"label": "wrap tables to page width",
"tooltip": "**force horizontally scrollable tables to respect the width and padding of a page when they overflow**",
"value": true "value": true
}, },
{ {
"type": "toggle",
"key": "tweak.snappy_transitions",
"label": "snappy transitions",
"tooltip": "enabling this **eliminates css animation time**, but will not prevent motion e.g. the sidebar popping out",
"value": false
},
{
"type": "toggle",
"key": "tweak.hide_help",
"label": "hide help button",
"value": false
},
{
"type": "toggle",
"key": "tweak.hide_slash_for_commands",
"label": "hide \"Type '/' for commands\"",
"value": false
},
{
"type": "toggle",
"key": "tweak.thicker_bold",
"label": "thicker bold text",
"value": true
},
{
"type": "toggle",
"key": "tweak.spaced_lines", "key": "tweak.spaced_lines",
"label": "readable line spacing", "label": "readable line spacing",
"tooltip": "greater line spacing between text blocks.", "tooltip": "**greater line spacing between text blocks**",
"type": "toggle",
"value": false "value": false
}, },
{ {
"type": "toggle",
"key": "tweak.condensed_bullets", "key": "tweak.condensed_bullets",
"label": "condense bullet points", "label": "condense bullet points",
"tooltip": "tighter line spacing between bullet point blocks.", "tooltip": "**tighter line spacing between bullet point blocks**",
"type": "toggle",
"value": false "value": false
}, },
{ {
"type": "toggle",
"key": "tweak.bracketed_links", "key": "tweak.bracketed_links",
"label": "bracketed links", "label": "bracketed links",
"tooltip": "render links surrounded with [[brackets]] instead of __underlined__.", "tooltip": "**render links surrounded with [[brackets]] instead of __underlined__**",
"type": "toggle",
"value": false "value": false
} }
] ]