mirror of
https://github.com/notion-enhancer/notion-enhancer.git
synced 2025-04-06 05:29:02 +00:00
separate always-on-top into separate mod
This commit is contained in:
parent
6ff3a96d81
commit
63e4b574a9
20
repo/alwaysontop/mod.js
Normal file
20
repo/alwaysontop/mod.js
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
/*
|
||||||
|
* always on top
|
||||||
|
* (c) 2020 dragonwocky <thedragonring.bod@gmail.com> (https://dragonwocky.me/)
|
||||||
|
* under the MIT license
|
||||||
|
*/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
// this is actually just a pseudo mod to "separate" the button
|
||||||
|
// from the core module, but the core still handles actually
|
||||||
|
// making it work.
|
||||||
|
module.exports = {
|
||||||
|
id: '72886371-dada-49a7-9afc-9f275ecf29d3',
|
||||||
|
tags: ['extension'],
|
||||||
|
name: 'always on top',
|
||||||
|
desc:
|
||||||
|
"add an arrow/button to show the notion window on top of other windows even if it's not focused.",
|
||||||
|
version: '0.1.1',
|
||||||
|
author: 'dragonwocky',
|
||||||
|
};
|
@ -15,7 +15,10 @@ module.exports = (store) => {
|
|||||||
buttons = {
|
buttons = {
|
||||||
element: helpers.createElement('<div class="window-buttons-area"></div>'),
|
element: helpers.createElement('<div class="window-buttons-area"></div>'),
|
||||||
insert: [
|
insert: [
|
||||||
'alwaysontop',
|
...((store('mods')['72886371-dada-49a7-9afc-9f275ecf29d3'] || {})
|
||||||
|
.enabled
|
||||||
|
? ['alwaysontop']
|
||||||
|
: []),
|
||||||
...(store().frameless && !store().tiling_mode && !is_mac
|
...(store().frameless && !store().tiling_mode && !is_mac
|
||||||
? ['minimize', 'maximize', 'close']
|
? ['minimize', 'maximize', 'close']
|
||||||
: []),
|
: []),
|
||||||
|
@ -105,19 +105,18 @@ s {
|
|||||||
|
|
||||||
#menu-titlebar {
|
#menu-titlebar {
|
||||||
display: flex;
|
display: flex;
|
||||||
padding: 0.4em;
|
|
||||||
-webkit-app-region: drag;
|
-webkit-app-region: drag;
|
||||||
}
|
}
|
||||||
#menu-titlebar button {
|
#menu-titlebar button {
|
||||||
-webkit-app-region: no-drag;
|
-webkit-app-region: no-drag;
|
||||||
}
|
}
|
||||||
#menu-titlebar :first-child {
|
|
||||||
margin-left: auto;
|
|
||||||
}
|
|
||||||
#menu-titlebar {
|
#menu-titlebar {
|
||||||
background: var(--theme--dragarea);
|
background: var(--theme--dragarea);
|
||||||
}
|
}
|
||||||
#menu-titlebar:empty {
|
#menu-titlebar > .window-buttons-area {
|
||||||
|
margin: 0.4em 0.4em 0.4em auto;
|
||||||
|
}
|
||||||
|
#menu-titlebar > .window-buttons-area:empty {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,32 +15,44 @@ const store = require('../../pkg/store.js'),
|
|||||||
browser = electron.remote.getCurrentWindow();
|
browser = electron.remote.getCurrentWindow();
|
||||||
|
|
||||||
window['__start'] = async () => {
|
window['__start'] = async () => {
|
||||||
if (!store(id).tiling_mode) {
|
const buttons = require('./buttons.js')(() => ({
|
||||||
const buttons = require('./buttons.js')(() => ({ frameless: true }));
|
'72886371-dada-49a7-9afc-9f275ecf29d3': {
|
||||||
document.querySelector('#menu-titlebar').appendChild(buttons.element);
|
enabled: (store('mods')['72886371-dada-49a7-9afc-9f275ecf29d3'] || {})
|
||||||
}
|
.enabled,
|
||||||
|
},
|
||||||
|
tiling_mode: store('0f0bf8b6-eae6-4273-b307-8fc43f2ee082').tiling_mode,
|
||||||
|
frameless: true,
|
||||||
|
}));
|
||||||
|
document.querySelector('#menu-titlebar').appendChild(buttons.element);
|
||||||
|
|
||||||
document.defaultView.addEventListener('keyup', (event) => {
|
document.defaultView.addEventListener('keyup', (event) => {
|
||||||
if (event.code === 'F5') location.reload();
|
if (event.code === 'F5') location.reload();
|
||||||
if (!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey) {
|
const meta =
|
||||||
|
!(event.ctrlKey || event.metaKey) && !event.altKey && !event.shiftKey;
|
||||||
|
if (
|
||||||
|
meta &&
|
||||||
|
document.activeElement.parentElement.id === 'tags' &&
|
||||||
|
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 (
|
if (
|
||||||
document.activeElement.parentElement.id === 'tags' &&
|
['Escape', 'Enter'].includes(event.key) &&
|
||||||
event.key === 'Enter'
|
document.activeElement.type !== 'checkbox' &&
|
||||||
|
(document.activeElement.parentElement.id !== 'search' ||
|
||||||
|
event.key === 'Escape')
|
||||||
)
|
)
|
||||||
document.activeElement.click();
|
document.activeElement.blur();
|
||||||
if (document.activeElement.tagName.toLowerCase() === 'input') {
|
} else if (
|
||||||
if (document.activeElement.type === 'checkbox' && event.key === 'Enter')
|
(meta && event.key === '/') ||
|
||||||
document.activeElement.checked = !document.activeElement.checked;
|
((event.ctrlKey || event.metaKey) &&
|
||||||
if (
|
event.key === 'f' &&
|
||||||
['Escape', 'Enter'].includes(event.key) &&
|
!event.altKey &&
|
||||||
document.activeElement.type !== 'checkbox' &&
|
!event.shiftKey)
|
||||||
(document.activeElement.parentElement.id !== 'search' ||
|
)
|
||||||
event.key === 'Escape')
|
document.querySelector('#search > input').focus();
|
||||||
)
|
|
||||||
document.activeElement.blur();
|
|
||||||
} else if (event.key === '/')
|
|
||||||
document.querySelector('#search > input').focus();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
electron.ipcRenderer.send('enhancer:get-theme-vars');
|
electron.ipcRenderer.send('enhancer:get-theme-vars');
|
||||||
|
Loading…
Reference in New Issue
Block a user