mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-04 04:39:03 +00:00
ext. menu search upgrades (more stuff is searchable + case insensitive + cmd/ctrl f)
This commit is contained in:
parent
ecdf9a70c0
commit
67f9ffaddb
@ -15,12 +15,14 @@ a feature and cleanup update.
|
||||
- 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`.
|
||||
- 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`
|
||||
- bugfix: made the open enhancements menu hotkey configurable and changed the default to `ALT+E`
|
||||
to remove conflict with the inline code highlight shortcut.
|
||||
- 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,
|
||||
@ -30,7 +32,6 @@ a feature and cleanup update.
|
||||
|
||||
// todo
|
||||
|
||||
- improved: extensions menu search now includes options.
|
||||
- improved: added individual text-colour rules for different background colours.
|
||||
- improved: added variables for callout colouring.
|
||||
- bugfix: block-level text colours are now changed properly.
|
||||
|
@ -95,7 +95,7 @@ team to take to heart for future improvements."
|
||||
## features
|
||||
|
||||
once applied, modules can be configured via the graphical menu, which is opened from
|
||||
the tray/menubar icon or with `CMD/CTRL+E`.
|
||||
the tray/menubar icon or with `ALT+E`.
|
||||
|
||||

|
||||
|
||||
|
@ -45,12 +45,13 @@ window['__start'] = async () => {
|
||||
event.key === 'Escape')
|
||||
)
|
||||
document.activeElement.blur();
|
||||
} else if (
|
||||
(meta && event.key === '/') ||
|
||||
((event.ctrlKey || event.metaKey) &&
|
||||
event.key === 'f' &&
|
||||
!event.altKey &&
|
||||
!event.shiftKey)
|
||||
} 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();
|
||||
});
|
||||
@ -171,7 +172,7 @@ window['__start'] = async () => {
|
||||
);
|
||||
|
||||
// search
|
||||
const search_query = {
|
||||
const search_filters = {
|
||||
enabled: true,
|
||||
disabled: true,
|
||||
tags: new Set(
|
||||
@ -181,19 +182,28 @@ window['__start'] = async () => {
|
||||
.sort()
|
||||
),
|
||||
};
|
||||
function innerText(elem) {
|
||||
let text = '';
|
||||
for (let node of elem.childNodes) {
|
||||
if (node.nodeType === 3) text += node.textContent;
|
||||
if (node.nodeType === 1)
|
||||
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');
|
||||
if (
|
||||
(mod.elem.classList.contains('enabled') && !search_query.enabled) ||
|
||||
(mod.elem.classList.contains('disabled') && !search_query.disabled) ||
|
||||
!mod.tags.some((tag) => search_query.tags.has(tag)) ||
|
||||
(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 &&
|
||||
!(
|
||||
mod.name +
|
||||
mod.tags.map((tag) => `#${tag}`).join(' ') +
|
||||
mod.desc
|
||||
).includes($search_input.value))
|
||||
!innerText(mod.elem)
|
||||
.toLowerCase()
|
||||
.includes($search_input.value.toLowerCase()))
|
||||
)
|
||||
return (mod.elem.style.display = 'none');
|
||||
mod.elem.style.display = 'block';
|
||||
@ -220,17 +230,17 @@ window['__start'] = async () => {
|
||||
}
|
||||
createTag(
|
||||
'enabled',
|
||||
(state) => [(search_query.enabled = state), search()]
|
||||
(state) => [(search_filters.enabled = state), search()]
|
||||
// 'var(--theme--bg_green)'
|
||||
);
|
||||
createTag(
|
||||
'disabled',
|
||||
(state) => [(search_query.disabled = state), search()]
|
||||
(state) => [(search_filters.disabled = state), search()]
|
||||
// 'var(--theme--bg_red)'
|
||||
);
|
||||
for (let tag of search_query.tags)
|
||||
for (let tag of search_filters.tags)
|
||||
createTag(`#${tag}`, (state) => [
|
||||
state ? search_query.tags.add(tag) : search_query.tags.delete(tag),
|
||||
state ? search_filters.tags.add(tag) : search_filters.tags.delete(tag),
|
||||
search(),
|
||||
]);
|
||||
|
||||
|
@ -30,10 +30,10 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
|
||||
const check_app = await require('./check.js')();
|
||||
switch (check_app.code) {
|
||||
case 1:
|
||||
console.log(`~~ notion-enhancer v${version} already applied.`);
|
||||
console.info(`~~ notion-enhancer v${version} already applied.`);
|
||||
return true;
|
||||
case 2:
|
||||
console.log(` * ${check_app.msg}`);
|
||||
console.warn(` * ${check_app.msg}`);
|
||||
do {
|
||||
process.stdout.write(' > overwrite? [Y/n]: ');
|
||||
overwrite_version = await helpers.readline();
|
||||
|
@ -68,7 +68,7 @@ module.exports = async function ({
|
||||
|
||||
// cleaning data folder: ~/.notion-enhancer
|
||||
if (await fs.pathExists(helpers.data_folder)) {
|
||||
console.log(` ...data folder ${helpers.data_folder} found.`);
|
||||
console.info(` ...data folder ${helpers.data_folder} found.`);
|
||||
if (delete_data === undefined) {
|
||||
do {
|
||||
process.stdout.write(' > delete? [Y/n]: ');
|
||||
|
Loading…
Reference in New Issue
Block a user