mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-08 06:29:03 +00:00
Compare commits
3 Commits
6dce77714e
...
75a864db8c
Author | SHA1 | Date | |
---|---|---|---|
75a864db8c | |||
493ab5aa63 | |||
71ed1ddb1f |
@ -9,6 +9,9 @@ import { Tooltip } from "./Tooltip.mjs";
|
|||||||
import { TopbarButton } from "./TopbarButton.mjs";
|
import { TopbarButton } from "./TopbarButton.mjs";
|
||||||
import { Select } from "../menu/islands/Select.mjs";
|
import { Select } from "../menu/islands/Select.mjs";
|
||||||
|
|
||||||
|
const topbarId = "e0700ce3-a9ae-45f5-92e5-610ded0e348d",
|
||||||
|
coreId = "0f0bf8b6-eae6-4273-b307-8fc43f2ee082";
|
||||||
|
|
||||||
// note: these islands are not reusable.
|
// note: these islands are not reusable.
|
||||||
// panel views can be added via addPanelView,
|
// panel views can be added via addPanelView,
|
||||||
// do not instantiate additional panels
|
// do not instantiate additional panels
|
||||||
@ -135,8 +138,7 @@ function Panel({
|
|||||||
</aside>
|
</aside>
|
||||||
</div>`;
|
</div>`;
|
||||||
|
|
||||||
const topbarId = "e0700ce3-a9ae-45f5-92e5-610ded0e348d",
|
const topbarFavorite = ".notion-topbar .notion-topbar-favorite-button",
|
||||||
topbarFavorite = ".notion-topbar .notion-topbar-favorite-button",
|
|
||||||
$topbarToggle = html`<${TopbarButton}
|
$topbarToggle = html`<${TopbarButton}
|
||||||
aria-label="Toggle side panel"
|
aria-label="Toggle side panel"
|
||||||
icon="panel-right"
|
icon="panel-right"
|
||||||
@ -207,7 +209,11 @@ function Panel({
|
|||||||
|
|
||||||
const animationState = { ...closedWidth },
|
const animationState = { ...closedWidth },
|
||||||
animate = ($target, keyframes) => {
|
animate = ($target, keyframes) => {
|
||||||
const opts = { fill: "forwards", duration: transitionDuration, easing: "ease" };
|
const opts = {
|
||||||
|
fill: "forwards",
|
||||||
|
duration: transitionDuration,
|
||||||
|
easing: "ease",
|
||||||
|
};
|
||||||
$target.animate(keyframes, opts);
|
$target.animate(keyframes, opts);
|
||||||
},
|
},
|
||||||
animatePanel = (to) => {
|
animatePanel = (to) => {
|
||||||
@ -278,8 +284,7 @@ function Panel({
|
|||||||
// hovering over the peek trigger will temporarily
|
// hovering over the peek trigger will temporarily
|
||||||
// pop out an interactive preview of the panel
|
// pop out an interactive preview of the panel
|
||||||
let _peekDebounce, _peekPanelOnHover;
|
let _peekDebounce, _peekPanelOnHover;
|
||||||
const coreId = "0f0bf8b6-eae6-4273-b307-8fc43f2ee082",
|
const $peekTrigger = html`<div
|
||||||
$peekTrigger = html`<div
|
|
||||||
class="absolute z-10 right-0 h-[calc(100vh-120px)] bottom-[60px] w-[96px]
|
class="absolute z-10 right-0 h-[calc(100vh-120px)] bottom-[60px] w-[96px]
|
||||||
group-[&[data-peeked]]/panel:(w-[calc(var(--panel--width,0)+8px)])
|
group-[&[data-peeked]]/panel:(w-[calc(var(--panel--width,0)+8px)])
|
||||||
group-[&[data-pinned]]/panel:(w-[calc(var(--panel--width,0)+8px)])"
|
group-[&[data-pinned]]/panel:(w-[calc(var(--panel--width,0)+8px)])"
|
||||||
|
@ -5,11 +5,14 @@
|
|||||||
* (https://notion-enhancer.github.io/) under the MIT license
|
* (https://notion-enhancer.github.io/) under the MIT license
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function LineNumber({ number, height, ...props }) {
|
function LineNumbers() {
|
||||||
const { html } = globalThis.__enhancerApi;
|
const { html } = globalThis.__enhancerApi;
|
||||||
return html`<span class="block text-right" style="height:${height}px">
|
return html`<div
|
||||||
${number}
|
class="notion-enhancer--line-numbers flex-grow
|
||||||
</span>`;
|
text-([85%] [var(--theme--fg-secondary)] right)
|
||||||
|
font-[var(--font--code)] pt-[34px] pb-[32px]
|
||||||
|
overflow-hidden"
|
||||||
|
></div>`;
|
||||||
}
|
}
|
||||||
|
|
||||||
export default async (api, db) => {
|
export default async (api, db) => {
|
||||||
@ -17,61 +20,75 @@ export default async (api, db) => {
|
|||||||
numberSingleLines = await db.get("numberSingleLines"),
|
numberSingleLines = await db.get("numberSingleLines"),
|
||||||
lineNumberDecoration = await db.get("lineNumberDecoration"),
|
lineNumberDecoration = await db.get("lineNumberDecoration"),
|
||||||
lineNumbersClass = "notion-enhancer--line-numbers",
|
lineNumbersClass = "notion-enhancer--line-numbers",
|
||||||
codeBlockSelector = ".notion-code-block.line-numbers";
|
codeBlockSelector = ".notion-code-block.line-numbers > .notranslate";
|
||||||
|
|
||||||
|
// get character width in pixels
|
||||||
|
const getCharWidth = ($elem) => {
|
||||||
|
const $char = html`<span style="width:1ch"> </span>`;
|
||||||
|
$elem.append($char);
|
||||||
|
const charWidth = getComputedStyle($char).getPropertyValue("width");
|
||||||
|
$char.remove();
|
||||||
|
return parseFloat(charWidth);
|
||||||
|
},
|
||||||
|
// get line width in pixels
|
||||||
|
getLineWidth = ($elem) =>
|
||||||
|
parseFloat(getComputedStyle($elem).getPropertyValue("width")) -
|
||||||
|
parseFloat(getComputedStyle($elem).getPropertyValue("padding-left")) -
|
||||||
|
parseFloat(getComputedStyle($elem).getPropertyValue("padding-right")),
|
||||||
|
// get line height in pixels
|
||||||
|
getLineHeight = ($elem) =>
|
||||||
|
parseFloat(getComputedStyle($elem).getPropertyValue("line-height")),
|
||||||
|
// update inline styles without unnecessary dom updates
|
||||||
|
applyStyles = ($elem, styles) => {
|
||||||
|
for (const property in styles) {
|
||||||
|
if ($elem.style[property] === styles[property]) continue;
|
||||||
|
$elem.style[property] = styles[property];
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
const numberLines = () => {
|
const numberLines = () => {
|
||||||
for (const $block of document.querySelectorAll(codeBlockSelector)) {
|
for (const $code of document.querySelectorAll(codeBlockSelector)) {
|
||||||
const $code = $block.lastElementChild,
|
|
||||||
computedStyles = getComputedStyle($code);
|
|
||||||
|
|
||||||
const wrap = $code.style.wordBreak === "break-all",
|
const wrap = $code.style.wordBreak === "break-all",
|
||||||
lines = $code.innerText.split("\n"),
|
lines = $code.innerText.split("\n"),
|
||||||
lineCount = Math.max(lines.length - 1, 1),
|
lineCount = Math.max(lines.length - 1, 1),
|
||||||
lineNumDigits = (Math.log(lineCount) * Math.LOG10E + 1) | 0;
|
lineNumDigits = (Math.log(lineCount) * Math.LOG10E + 1) | 0;
|
||||||
|
|
||||||
const update =
|
const doUpdate =
|
||||||
parseInt($block.dataset.lines) !== lineCount ||
|
$code.dataset.lines !== String(lineCount) ||
|
||||||
$block.dataset.wrap !== String(wrap);
|
$code.dataset.wrap !== String(wrap);
|
||||||
if (!update) continue;
|
if (!doUpdate) continue;
|
||||||
$block.dataset.lines = lineCount;
|
$code.dataset.lines = lineCount;
|
||||||
$block.dataset.wrap = wrap;
|
$code.dataset.wrap = wrap;
|
||||||
|
|
||||||
// shrink block to allow space for numbers
|
// shrink block to allow space for numbers
|
||||||
$block.style.justifyContent = "flex-end";
|
const width = `calc(100% - 32px - ${lineNumDigits}ch)`;
|
||||||
$code.style.minWidth = `calc(100% - 32px - ${lineNumDigits}ch)`;
|
applyStyles($code.parentElement, { justifyContent: "flex-end" });
|
||||||
$code.style.maxWidth = $code.style.minWidth;
|
applyStyles($code, { minWidth: width, maxWidth: width });
|
||||||
|
|
||||||
// get 1ch in pixels
|
|
||||||
const $tmp = html`<span style="width:1ch"> </span>`;
|
|
||||||
$code.append($tmp);
|
|
||||||
const charWidth = getComputedStyle($tmp).getPropertyValue("width");
|
|
||||||
$tmp.remove();
|
|
||||||
|
|
||||||
// work out height of wrapped lines
|
// work out height of wrapped lines
|
||||||
const lineWidth =
|
const lineHeight = getLineHeight($code),
|
||||||
parseFloat(computedStyles.getPropertyValue("width")) -
|
charsPerLine = Math.floor(getLineWidth($code) / getCharWidth($code));
|
||||||
parseFloat(computedStyles.getPropertyValue("padding-left")) -
|
|
||||||
parseFloat(computedStyles.getPropertyValue("padding-right")),
|
|
||||||
charsPerLine = Math.floor(lineWidth / parseFloat(charWidth)),
|
|
||||||
lineHeight = parseFloat(computedStyles.getPropertyValue("line-height"));
|
|
||||||
|
|
||||||
const $numbers = html`<div
|
// update line numbers in dom
|
||||||
class="${lineNumbersClass} font-[var(--font--code)] flex-grow
|
let totalHeight = 34;
|
||||||
text-([85%] [var(--theme--fg-secondary)] right) pt-[34px] pb-[32px]"
|
$code._$lineNumbers ||= LineNumbers();
|
||||||
></div>`;
|
|
||||||
for (let i = 1; i <= lineCount; i++) {
|
for (let i = 1; i <= lineCount; i++) {
|
||||||
let lineSpan = 1;
|
let $n = $code._$lineNumbers.children[i - 1];
|
||||||
if (wrap) lineSpan = Math.ceil(lines[i - 1].length / charsPerLine);
|
if (!$n) {
|
||||||
$numbers.append(
|
$n = html`<span class="block text-right">${i}</span>`;
|
||||||
html`<${LineNumber}
|
$code._$lineNumbers.append($n);
|
||||||
number=${i}
|
|
||||||
height=${(lineSpan || 1) * lineHeight}
|
|
||||||
/>`
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
const height =
|
||||||
|
wrap && lines[i - 1].length > charsPerLine
|
||||||
|
? Math.ceil(lines[i - 1].length / charsPerLine) * lineHeight
|
||||||
|
: lineHeight;
|
||||||
|
applyStyles($n, { height: `${height}px` });
|
||||||
|
totalHeight += height;
|
||||||
|
}
|
||||||
|
applyStyles($code._$lineNumbers, { height: `${totalHeight}px` });
|
||||||
|
|
||||||
const $prev = $block.getElementsByClassName(lineNumbersClass)[0];
|
if (!document.contains($code._$lineNumbers))
|
||||||
$prev ? $prev.replaceWith($numbers) : $block.prepend($numbers);
|
$code.before($code._$lineNumbers);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,18 +1,44 @@
|
|||||||
/**
|
/**
|
||||||
* notion-enhancer: tweaks
|
* notion-enhancer: tweaks
|
||||||
* (c) 2024 1280px
|
|
||||||
* (c) 2020 Arecsu
|
* (c) 2020 Arecsu
|
||||||
|
* (c) 2024 1280px
|
||||||
* (c) 2024 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
* (c) 2024 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
/* interface */
|
||||||
|
|
||||||
|
/* pages */
|
||||||
|
|
||||||
|
body[data-tweaks*=",normalisedDatabaseScrolling,"] {
|
||||||
|
.notion-page-content {
|
||||||
|
.notion-collection_view-block {
|
||||||
|
width: 100% !important;
|
||||||
|
}
|
||||||
|
.notion-board-view {
|
||||||
|
margin-left: 0 !important;
|
||||||
|
margin-right: 0 !important;
|
||||||
|
}
|
||||||
|
:is(.notion-collection_view-block, .notion-collection-view-body)
|
||||||
|
> [style*="padding"] {
|
||||||
|
padding-left: 0 !important;
|
||||||
|
padding-right: 0 !important;
|
||||||
|
min-width: auto !important;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* typography */
|
||||||
|
|
||||||
.enhancer--tweak-responsive_breakpoint
|
.enhancer--tweak-responsive_breakpoint
|
||||||
.notion-column_list-block
|
.notion-column_list-block
|
||||||
[style='display: flex;']
|
[style="display: flex;"]
|
||||||
> div {
|
> div {
|
||||||
width: 100% !important;
|
width: 100% !important;
|
||||||
}
|
}
|
||||||
.enhancer--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;
|
||||||
}
|
}
|
||||||
.enhancer--tweak-responsive_breakpoint .notion-app-inner,
|
.enhancer--tweak-responsive_breakpoint .notion-app-inner,
|
||||||
@ -21,29 +47,6 @@
|
|||||||
--theme--page-padding: calc(48px + env(safe-area-inset-left));
|
--theme--page-padding: calc(48px + env(safe-area-inset-left));
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-normalise_table_scroll
|
|
||||||
.notion-frame
|
|
||||||
.notion-page-content
|
|
||||||
.notion-collection_view-block,
|
|
||||||
.enhancer--tweak-normalise_table_scroll .notion-peek-renderer .notion-collection_view-block,
|
|
||||||
.enhancer--tweak-normalise_table_scroll
|
|
||||||
.notion-page-template-modal
|
|
||||||
.notion-collection_view-block,
|
|
||||||
.enhancer--tweak-normalise_table_dscroll .notion-collection-view-body .notion-table-view {
|
|
||||||
width: 100% !important;
|
|
||||||
padding: 0 !important;
|
|
||||||
}
|
|
||||||
.enhancer--tweak-normalise_table_scroll
|
|
||||||
.notion-collection_view-block
|
|
||||||
> [contenteditable]
|
|
||||||
> .notion-scroller
|
|
||||||
> [class$='view'][style*='padding'],
|
|
||||||
.enhancer--tweak-normalise_table_scroll
|
|
||||||
.notion-collection_view-block
|
|
||||||
> :first-child[style*='padding-right'] {
|
|
||||||
padding: 1px !important;
|
|
||||||
}
|
|
||||||
|
|
||||||
.enhancer--tweak-snappy_transitions * {
|
.enhancer--tweak-snappy_transitions * {
|
||||||
animation-duration: 0s !important;
|
animation-duration: 0s !important;
|
||||||
transition-duration: 0s !important;
|
transition-duration: 0s !important;
|
||||||
@ -57,26 +60,39 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-hide_slash_for_commands [contenteditable]:empty:after {
|
.enhancer--tweak-hide_slash_for_commands [contenteditable]:empty:after {
|
||||||
content: ' ' !important;
|
content: " " !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-hide_default_page_icons
|
.enhancer--tweak-hide_default_page_icons
|
||||||
.notion-sidebar a > div > div:has(.notion-record-icon svg.page),
|
.notion-sidebar
|
||||||
|
a
|
||||||
|
> div
|
||||||
|
> div:has(.notion-record-icon svg.page),
|
||||||
.enhancer--tweak-hide_default_page_icons
|
.enhancer--tweak-hide_default_page_icons
|
||||||
.layout a > div > div > div > div:has(.notion-record-icon svg.page) {
|
.layout
|
||||||
|
a
|
||||||
|
> div
|
||||||
|
> div
|
||||||
|
> div
|
||||||
|
> div:has(.notion-record-icon svg.page) {
|
||||||
display: none !important;
|
display: none !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-thicker_bold .notion-page-content span[style*='font-weight:600'] {
|
.enhancer--tweak-thicker_bold
|
||||||
|
.notion-page-content
|
||||||
|
span[style*="font-weight:600"] {
|
||||||
font-weight: 700 !important;
|
font-weight: 700 !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-spaced_lines .notion-page-content .notion-selectable.notion-text-block {
|
.enhancer--tweak-spaced_lines
|
||||||
|
.notion-page-content
|
||||||
|
.notion-selectable.notion-text-block {
|
||||||
line-height: 1.65 !important;
|
line-height: 1.65 !important;
|
||||||
margin-top: 0.75em !important;
|
margin-top: 0.75em !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-condensed_bullets .notion-selectable.notion-bulleted_list-block {
|
.enhancer--tweak-condensed_bullets
|
||||||
|
.notion-selectable.notion-bulleted_list-block {
|
||||||
margin-top: -1.5px !important;
|
margin-top: -1.5px !important;
|
||||||
margin-bottom: -1.5px !important;
|
margin-bottom: -1.5px !important;
|
||||||
}
|
}
|
||||||
@ -85,12 +101,12 @@
|
|||||||
border-bottom: none !important;
|
border-bottom: none !important;
|
||||||
}
|
}
|
||||||
.enhancer--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;
|
||||||
}
|
}
|
||||||
.enhancer--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;
|
||||||
}
|
}
|
||||||
@ -102,32 +118,42 @@
|
|||||||
.enhancer--tweak-accented_links .notion-link-token {
|
.enhancer--tweak-accented_links .notion-link-token {
|
||||||
color: var(--theme--accent_blue) !important;
|
color: var(--theme--accent_blue) !important;
|
||||||
}
|
}
|
||||||
.enhancer--tweak-accented_links .notion-link-token span[style*='border-bottom:0.05em'] {
|
.enhancer--tweak-accented_links
|
||||||
|
.notion-link-token
|
||||||
|
span[style*="border-bottom:0.05em"] {
|
||||||
opacity: 1 !important;
|
opacity: 1 !important;
|
||||||
border-color: var(--theme--accent_blue) !important;
|
border-color: var(--theme--accent_blue) !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
.enhancer--tweak-quotation_marks
|
.enhancer--tweak-quotation_marks
|
||||||
.notion-quote-block
|
.notion-quote-block
|
||||||
[style*='border-left: 3px solid currentcolor;'] {
|
[style*="border-left: 3px solid currentcolor;"] {
|
||||||
position: relative;
|
position: relative;
|
||||||
padding-left: 24px !important;
|
padding-left: 24px !important;
|
||||||
padding-right: 18px !important;
|
padding-right: 18px !important;
|
||||||
}
|
}
|
||||||
.enhancer--tweak-quotation_marks .notion-quote-block [placeholder='Empty quote']::before,
|
.enhancer--tweak-quotation_marks
|
||||||
.enhancer--tweak-quotation_marks .notion-quote-block [placeholder='Empty quote']::after {
|
.notion-quote-block
|
||||||
|
[placeholder="Empty quote"]::before,
|
||||||
|
.enhancer--tweak-quotation_marks
|
||||||
|
.notion-quote-block
|
||||||
|
[placeholder="Empty quote"]::after {
|
||||||
font-family: Georgia, serif;
|
font-family: Georgia, serif;
|
||||||
font-size: 24px;
|
font-size: 24px;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
}
|
}
|
||||||
.enhancer--tweak-quotation_marks .notion-quote-block [placeholder='Empty quote']::before {
|
.enhancer--tweak-quotation_marks
|
||||||
content: '\201C';
|
.notion-quote-block
|
||||||
|
[placeholder="Empty quote"]::before {
|
||||||
|
content: "\201C";
|
||||||
left: 8px;
|
left: 8px;
|
||||||
top: -2px;
|
top: -2px;
|
||||||
}
|
}
|
||||||
.enhancer--tweak-quotation_marks .notion-quote-block [placeholder='Empty quote']::after {
|
.enhancer--tweak-quotation_marks
|
||||||
content: '\201D';
|
.notion-quote-block
|
||||||
|
[placeholder="Empty quote"]::after {
|
||||||
|
content: "\201D";
|
||||||
right: 2px;
|
right: 2px;
|
||||||
bottom: -2px;
|
bottom: -2px;
|
||||||
}
|
}
|
||||||
|
@ -1,56 +1,17 @@
|
|||||||
/**
|
/**
|
||||||
* notion-enhancer: tweaks
|
* notion-enhancer: tweaks
|
||||||
* (c) 2021 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
* (c) 2024 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
|
||||||
*/
|
*/
|
||||||
|
|
||||||
'use strict';
|
const tweaksId = "5174a483-c88d-4bf8-a95f-35cd330b76e2";
|
||||||
|
export default async (api, db) => {
|
||||||
|
const { getMods } = api,
|
||||||
|
[{ options }] = await getMods((mod) => mod.id === tweaksId),
|
||||||
|
tweaks = options.filter((opt) => opt.key).map((opt) => opt.key);
|
||||||
|
|
||||||
export default async function ({ web }, db) {
|
// inc. leading & trailing comma for selectors (see client.css)
|
||||||
const cssInsert = await db.get(['insert.css']);
|
let enabled = ",";
|
||||||
if (cssInsert?.filename) {
|
for (const tweak of tweaks) if (await db.get(tweak)) enabled += tweak + ",";
|
||||||
document.head.append(
|
document.body.dataset.tweaks = enabled;
|
||||||
web.html`<style id="enhancer--tweak-${cssInsert.filename}">${cssInsert.content}</style>`
|
};
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
const responsiveBreakpointPx = +(await db.get(['tweak.responsive_breakpoint_px'])),
|
|
||||||
responsiveBreakpointPercent =
|
|
||||||
screen.width * 0.01 * (await db.get(['tweak.responsive_breakpoint_percent'])),
|
|
||||||
addResponsiveBreakpoint = () => {
|
|
||||||
document.body.classList.remove('enhancer--tweak-responsive_breakpoint');
|
|
||||||
if (
|
|
||||||
window.innerWidth <= responsiveBreakpointPx ||
|
|
||||||
window.innerWidth <= responsiveBreakpointPercent
|
|
||||||
) {
|
|
||||||
document.body.classList.add('enhancer--tweak-responsive_breakpoint');
|
|
||||||
}
|
|
||||||
};
|
|
||||||
addEventListener('resize', addResponsiveBreakpoint);
|
|
||||||
addResponsiveBreakpoint();
|
|
||||||
|
|
||||||
const tweaks = [
|
|
||||||
'full_width_pages',
|
|
||||||
'normalise_table_scroll',
|
|
||||||
'hide_help',
|
|
||||||
'hide_slash_for_commands',
|
|
||||||
'hide_default_page_icons',
|
|
||||||
'snappy_transitions',
|
|
||||||
'thicker_bold',
|
|
||||||
'spaced_lines',
|
|
||||||
'condensed_bullets',
|
|
||||||
'bracketed_links',
|
|
||||||
'accented_links',
|
|
||||||
'quotation_marks',
|
|
||||||
];
|
|
||||||
for (const tweak of tweaks) {
|
|
||||||
if (await db.get([`tweak.${tweak}`])) {
|
|
||||||
document.body.classList.add(`enhancer--tweak-${tweak}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const imgAlignment = await db.get(['tweak.img_alignment']);
|
|
||||||
if (imgAlignment !== 'center') {
|
|
||||||
document.body.classList.add(`enhancer--tweak-img_alignment-${imgAlignment}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
@ -59,9 +59,9 @@
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "toggle",
|
"type": "toggle",
|
||||||
"key": "normalisedTableScrolling",
|
"key": "normalisedDatabaseScrolling",
|
||||||
"description": "Forces horizontally scrollable inline tables to respect the width and padding of a page when they overflow.",
|
"description": "Forces horizontally scrollable inline tables to respect the width and padding of a page when they overflow. Enabling this is recommended if you are using panel mods, otherwise databases may overflow.",
|
||||||
"value": false
|
"value": true
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"type": "number",
|
"type": "number",
|
||||||
@ -130,5 +130,7 @@
|
|||||||
"description": "Changes the default horizontal alignment of images embedded within pages. Note that this replaces Notion's built-in central alignment, i.e. setting this to left or right will remove the option to centre images entirely.",
|
"description": "Changes the default horizontal alignment of images embedded within pages. Note that this replaces Notion's built-in central alignment, i.e. setting this to left or right will remove the option to centre images entirely.",
|
||||||
"values": ["Centre", "Left", "Right"]
|
"values": ["Centre", "Left", "Right"]
|
||||||
}
|
}
|
||||||
]
|
],
|
||||||
|
"clientStyles": ["client.css"],
|
||||||
|
"clientScripts": ["client.mjs"]
|
||||||
}
|
}
|
||||||
|
13
src/init.js
13
src/init.js
@ -6,12 +6,13 @@
|
|||||||
|
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
const isElectron = () => {
|
const coreId = "0f0bf8b6-eae6-4273-b307-8fc43f2ee082",
|
||||||
|
isElectron = () => {
|
||||||
try {
|
try {
|
||||||
return typeof module !== "undefined";
|
return typeof module !== "undefined";
|
||||||
} catch {}
|
} catch {}
|
||||||
return false;
|
return false;
|
||||||
};
|
};
|
||||||
|
|
||||||
if (isElectron()) {
|
if (isElectron()) {
|
||||||
require("./api/system.js");
|
require("./api/system.js");
|
||||||
@ -38,8 +39,8 @@ if (isElectron()) {
|
|||||||
|
|
||||||
// register user-provided javascript for execution in-app
|
// register user-provided javascript for execution in-app
|
||||||
if (target === ".webpack/renderer/tab_browser_view/preload.js") {
|
if (target === ".webpack/renderer/tab_browser_view/preload.js") {
|
||||||
const { webFrame } = require("electron"),
|
const db = await modDatabase(coreId),
|
||||||
db = await modDatabase("0f0bf8b6-eae6-4273-b307-8fc43f2ee082"),
|
{ webFrame } = require("electron"),
|
||||||
customScript = (await db.get("customScript"))?.content;
|
customScript = (await db.get("customScript"))?.content;
|
||||||
if (customScript) webFrame.executeJavaScript(customScript);
|
if (customScript) webFrame.executeJavaScript(customScript);
|
||||||
}
|
}
|
||||||
@ -52,8 +53,12 @@ if (isElectron()) {
|
|||||||
const db = await modDatabase(mod.id);
|
const db = await modDatabase(mod.id);
|
||||||
for (let [scriptTarget, script] of mod.electronScripts ?? []) {
|
for (let [scriptTarget, script] of mod.electronScripts ?? []) {
|
||||||
if (target !== scriptTarget) continue;
|
if (target !== scriptTarget) continue;
|
||||||
|
try {
|
||||||
script = require(`./${mod._src}/${script}`);
|
script = require(`./${mod._src}/${script}`);
|
||||||
script(__getApi(), db, __exports, __eval);
|
script(__getApi(), db, __exports, __eval);
|
||||||
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -72,7 +72,8 @@ export default (async () => {
|
|||||||
Promise.resolve(isCore || API_LOADED)
|
Promise.resolve(isCore || API_LOADED)
|
||||||
.then(() => import(enhancerUrl(`${mod._src}/${script}`)))
|
.then(() => import(enhancerUrl(`${mod._src}/${script}`)))
|
||||||
.then((script) => script.default(globalThis.__enhancerApi, db))
|
.then((script) => script.default(globalThis.__enhancerApi, db))
|
||||||
.then(() => !isCore || globalThis.__enhancerApi.onReady?.());
|
.then(() => !isCore || globalThis.__enhancerApi.onReady?.())
|
||||||
|
.catch((err) => console.error(err));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user