ext. menu search upgrades (more stuff is searchable + case insensitive + cmd/ctrl f)

This commit is contained in:
dragonwocky 2020-09-02 22:21:17 +10:00
parent ecdf9a70c0
commit 67f9ffaddb
Signed by: dragonwocky
GPG Key ID: C7A48B7846AA706D
5 changed files with 36 additions and 25 deletions

View File

@ -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 - improved: font imports must be define in the `mod.js` so that they can also be used in
the enhancements menu. the enhancements menu.
- improved: tiling window-manager support (can hide titlebars entirely without dragarea/buttons). - 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 - bugfix: enhancer settings should no longer reset on update (though this will not have
effect until the release after this one). effect until the release after this one).
- bugfix: blue select tags are no longer purple. - bugfix: blue select tags are no longer purple.
- bugfix: page titles now respond to small-text mode. - bugfix: page titles now respond to small-text mode.
- bugfix: weekly calendar view height is now sized correctly according to its contents. - 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. to remove conflict with the inline code highlight shortcut.
- themes: "littlepig" (light + dark) = monospaced themes using emojis and colourful text. - 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, - 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 // todo
- improved: extensions menu search now includes options.
- improved: added individual text-colour rules for different background colours. - improved: added individual text-colour rules for different background colours.
- improved: added variables for callout colouring. - improved: added variables for callout colouring.
- bugfix: block-level text colours are now changed properly. - bugfix: block-level text colours are now changed properly.

View File

@ -95,7 +95,7 @@ team to take to heart for future improvements."
## features ## features
once applied, modules can be configured via the graphical menu, which is opened from 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`.
![](https://user-images.githubusercontent.com/16874139/91446210-84ee6b00-e8ba-11ea-9f40-187a150e4a82.png) ![](https://user-images.githubusercontent.com/16874139/91446210-84ee6b00-e8ba-11ea-9f40-187a150e4a82.png)

View File

@ -45,12 +45,13 @@ window['__start'] = async () => {
event.key === 'Escape') event.key === 'Escape')
) )
document.activeElement.blur(); document.activeElement.blur();
} else if ( } else if (meta && event.key === '/')
(meta && event.key === '/') || document.querySelector('#search > input').focus();
((event.ctrlKey || event.metaKey) && if (
event.key === 'f' && (event.ctrlKey || event.metaKey) &&
!event.altKey && event.key === 'f' &&
!event.shiftKey) !event.altKey &&
!event.shiftKey
) )
document.querySelector('#search > input').focus(); document.querySelector('#search > input').focus();
}); });
@ -171,7 +172,7 @@ window['__start'] = async () => {
); );
// search // search
const search_query = { const search_filters = {
enabled: true, enabled: true,
disabled: true, disabled: true,
tags: new Set( tags: new Set(
@ -181,19 +182,28 @@ window['__start'] = async () => {
.sort() .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() { function search() {
modules.loaded.forEach((mod) => { modules.loaded.forEach((mod) => {
const $search_input = document.querySelector('#search > input'); const $search_input = document.querySelector('#search > input');
if ( if (
(mod.elem.classList.contains('enabled') && !search_query.enabled) || (mod.elem.classList.contains('enabled') && !search_filters.enabled) ||
(mod.elem.classList.contains('disabled') && !search_query.disabled) || (mod.elem.classList.contains('disabled') && !search_filters.disabled) ||
!mod.tags.some((tag) => search_query.tags.has(tag)) || !mod.tags.some((tag) => search_filters.tags.has(tag)) ||
($search_input.value && ($search_input.value &&
!( !innerText(mod.elem)
mod.name + .toLowerCase()
mod.tags.map((tag) => `#${tag}`).join(' ') + .includes($search_input.value.toLowerCase()))
mod.desc
).includes($search_input.value))
) )
return (mod.elem.style.display = 'none'); return (mod.elem.style.display = 'none');
mod.elem.style.display = 'block'; mod.elem.style.display = 'block';
@ -220,17 +230,17 @@ window['__start'] = async () => {
} }
createTag( createTag(
'enabled', 'enabled',
(state) => [(search_query.enabled = state), search()] (state) => [(search_filters.enabled = state), search()]
// 'var(--theme--bg_green)' // 'var(--theme--bg_green)'
); );
createTag( createTag(
'disabled', 'disabled',
(state) => [(search_query.disabled = state), search()] (state) => [(search_filters.disabled = state), search()]
// 'var(--theme--bg_red)' // 'var(--theme--bg_red)'
); );
for (let tag of search_query.tags) for (let tag of search_filters.tags)
createTag(`#${tag}`, (state) => [ 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(), search(),
]); ]);

View File

@ -30,10 +30,10 @@ module.exports = async function ({ overwrite_version, friendly_errors } = {}) {
const check_app = await require('./check.js')(); const check_app = await require('./check.js')();
switch (check_app.code) { switch (check_app.code) {
case 1: case 1:
console.log(`~~ notion-enhancer v${version} already applied.`); console.info(`~~ notion-enhancer v${version} already applied.`);
return true; return true;
case 2: case 2:
console.log(` * ${check_app.msg}`); console.warn(` * ${check_app.msg}`);
do { do {
process.stdout.write(' > overwrite? [Y/n]: '); process.stdout.write(' > overwrite? [Y/n]: ');
overwrite_version = await helpers.readline(); overwrite_version = await helpers.readline();

View File

@ -68,7 +68,7 @@ module.exports = async function ({
// cleaning data folder: ~/.notion-enhancer // cleaning data folder: ~/.notion-enhancer
if (await fs.pathExists(helpers.data_folder)) { 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) { if (delete_data === undefined) {
do { do {
process.stdout.write(' > delete? [Y/n]: '); process.stdout.write(' > delete? [Y/n]: ');