mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
converting more keyboard shortcuts
This commit is contained in:
parent
d103b16d9a
commit
370c63986d
12
package-lock.json
generated
12
package-lock.json
generated
@ -1001,9 +1001,9 @@
|
||||
"integrity": "sha512-ReZxvNHIOv88FlT7rxcXIIC0fPt4KZqZbOlivyWtXLt8ESx84zd3kMC6iK5jVeS2qt+g7ftS7ye4fi06X5rtRQ=="
|
||||
},
|
||||
"axios": {
|
||||
"version": "0.19.1",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.1.tgz",
|
||||
"integrity": "sha512-Yl+7nfreYKaLRvAvjNPkvfjnQHJM1yLBY3zhqAwcJSwR/6ETkanUgylgtIvkvz0xJ+p/vZuNw8X7Hnb7Whsbpw==",
|
||||
"version": "0.19.2",
|
||||
"resolved": "https://registry.npmjs.org/axios/-/axios-0.19.2.tgz",
|
||||
"integrity": "sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==",
|
||||
"requires": {
|
||||
"follow-redirects": "1.5.10"
|
||||
}
|
||||
@ -3987,9 +3987,9 @@
|
||||
}
|
||||
},
|
||||
"file-type": {
|
||||
"version": "13.1.1",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-13.1.1.tgz",
|
||||
"integrity": "sha512-HEb3tepyq8KzKSFEGMJSIxqn8uC1n3AM8OKME5+BIgq0bErRzcDPOdmnyPKtfjStSpIvuk0Rle8mvuG4824caQ==",
|
||||
"version": "13.1.2",
|
||||
"resolved": "https://registry.npmjs.org/file-type/-/file-type-13.1.2.tgz",
|
||||
"integrity": "sha512-NiHXbmclwHN38eHZfRklosbm7/W+1yacDzRCyddd0NiyuJUArQDmzJ8GPSFJGl82+I59u7sNGfcAVnJsfXJb8A==",
|
||||
"requires": {
|
||||
"readable-web-to-node-stream": "^2.0.0",
|
||||
"strtok3": "^5.0.2",
|
||||
|
@ -21,7 +21,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"async-mutex": "0.1.4",
|
||||
"axios": "0.19.1",
|
||||
"axios": "0.19.2",
|
||||
"body-parser": "1.19.0",
|
||||
"cls-hooked": "4.2.2",
|
||||
"commonmark": "0.29.1",
|
||||
@ -37,7 +37,7 @@
|
||||
"electron-window-state": "5.0.3",
|
||||
"express": "4.17.1",
|
||||
"express-session": "1.17.0",
|
||||
"file-type": "13.1.1",
|
||||
"file-type": "13.1.2",
|
||||
"fs-extra": "8.1.0",
|
||||
"helmet": "3.21.2",
|
||||
"html": "1.0.0",
|
||||
|
@ -41,7 +41,6 @@ export default class Entrypoints extends Component {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
findInTextListener() {
|
||||
if (utils.isElectron()) {
|
||||
const {remote} = require('electron');
|
||||
@ -113,4 +112,68 @@ export default class Entrypoints extends Component {
|
||||
copyWithoutFormattingListener() {
|
||||
utils.copySelectionToClipboard();
|
||||
}
|
||||
}
|
||||
|
||||
toggleFullscreenListener() {
|
||||
if (utils.isElectron()) {
|
||||
const win = require('electron').remote.getCurrentWindow();
|
||||
|
||||
if (win.isFullScreenable()) {
|
||||
win.setFullScreen(!win.isFullScreen());
|
||||
}
|
||||
}
|
||||
else {
|
||||
// outside of electron this is handled by the browser
|
||||
this.$widget.find(".toggle-fullscreen-button").hide();
|
||||
}
|
||||
}
|
||||
|
||||
toggleZenModeListener() {
|
||||
if (!this.zenModeActive) {
|
||||
$(".hide-in-zen-mode,.gutter").addClass("hidden-by-zen-mode");
|
||||
$("#container").addClass("zen-mode");
|
||||
this.zenModeActive = true;
|
||||
}
|
||||
else {
|
||||
// not hiding / showing explicitly since element might be hidden also for other reasons
|
||||
$(".hide-in-zen-mode,.gutter").removeClass("hidden-by-zen-mode");
|
||||
$("#container").removeClass("zen-mode");
|
||||
this.zenModeActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
reloadFrontendAppListener() {
|
||||
utils.reloadApp();
|
||||
}
|
||||
|
||||
logoutListener() {
|
||||
const $logoutForm = $('<form action="logout" method="POST">')
|
||||
.append($(`<input type="hidden" name="_csrf" value="${glob.csrfToken}"/>`));
|
||||
|
||||
$("body").append($logoutForm);
|
||||
$logoutForm.trigger('submit');
|
||||
}
|
||||
|
||||
showOptionsListener() {
|
||||
import("../dialogs/options.js").then(d => d.showDialog())
|
||||
}
|
||||
|
||||
showHelpListener() {
|
||||
import("../dialogs/help.js").then(d => d.showDialog())
|
||||
}
|
||||
|
||||
showSQLConsoleListener() {
|
||||
import("../dialogs/sql_console.js").then(d => d.showDialog())
|
||||
}
|
||||
|
||||
showBackendLogListener() {
|
||||
import("../dialogs/backend_log.js").then(d => d.showDialog())
|
||||
}
|
||||
|
||||
backInNoteHistoryListener() {
|
||||
window.history.back();
|
||||
}
|
||||
|
||||
forwardInNoteHistoryListener() {
|
||||
window.history.forward();
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,6 @@ import keyboardActionService from "../services/keyboard_actions.js";
|
||||
import utils from "../services/utils.js";
|
||||
import syncService from "../services/sync.js";
|
||||
|
||||
const OPTIONS = "../dialogs/options.js";
|
||||
const SQL_CONSOLE = "../dialogs/sql_console.js";
|
||||
const BACKEND_LOG = "../dialogs/backend_log.js";
|
||||
const HELP = "../dialogs/help.js";
|
||||
const ABOUT = "../dialogs/about.js";
|
||||
|
||||
const TPL = `
|
||||
<div class="global-menu-wrapper">
|
||||
<style>
|
||||
@ -45,43 +39,44 @@ const TPL = `
|
||||
Sync (<span id="outstanding-syncs-count">0</span>)
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item open-dev-tools-button">
|
||||
<a class="dropdown-item open-dev-tools-button" data-trigger-event="openDevTools">
|
||||
<span class="bx bx-terminal"></span>
|
||||
Open Dev Tools
|
||||
<kbd data-kb-action="OpenDevTools"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item open-sql-console-button">
|
||||
<a class="dropdown-item open-sql-console-button" data-trigger-event="showSQLConsole">
|
||||
<span class="bx bx-data"></span>
|
||||
Open SQL Console
|
||||
<kbd data-kb-action="ShowSQLConsole"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item show-backend-log-button">
|
||||
<a class="dropdown-item show-backend-log-button" data-trigger-event="showBackendLog">
|
||||
<span class="bx bx-empty"></span>
|
||||
Show backend log
|
||||
<kbd data-kb-action="ShowBackendLog"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item reload-frontend-button" title="Reload can help with some visual glitches without restarting the whole app.">
|
||||
<a class="dropdown-item reload-frontend-button" data-trigger-event="reloadFrontendApp"
|
||||
title="Reload can help with some visual glitches without restarting the whole app.">
|
||||
<span class="bx bx-empty"></span>
|
||||
Reload frontend
|
||||
<kbd data-kb-action="ReloadFrontendApp"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item toggle-zen-mode-button">
|
||||
<a class="dropdown-item toggle-zen-mode-button" data-trigger-event="toggleZenMode">
|
||||
<span class="bx bx-empty"></span>
|
||||
Toggle Zen mode
|
||||
<kbd data-kb-action="ToggleZenMode"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item toggle-fullscreen-button">
|
||||
<a class="dropdown-item toggle-fullscreen-button" data-trigger-event="toggleFullscreen">
|
||||
<span class="bx bx-empty"></span>
|
||||
Toggle fullscreen
|
||||
<kbd data-kb-action="ToggleFullscreen"></kbd>
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item show-help-button">
|
||||
<a class="dropdown-item show-help-button" data-trigger-event="showHelp">
|
||||
<span class="bx bx-info-circle"></span>
|
||||
Show Help
|
||||
<kbd data-kb-action="ShowHelp"></kbd>
|
||||
@ -92,7 +87,7 @@ const TPL = `
|
||||
About Trilium Notes
|
||||
</a>
|
||||
|
||||
<a class="dropdown-item logout-button">
|
||||
<a class="dropdown-item logout-button" data-trigger-event="logout">
|
||||
<span class="bx bx-log-out"></span>
|
||||
Logout
|
||||
</a>
|
||||
@ -105,80 +100,14 @@ export default class GlobalMenuWidget extends BasicWidget {
|
||||
render() {
|
||||
this.$widget = $(TPL);
|
||||
|
||||
let zenModeActive = false;
|
||||
|
||||
// hide (toggle) everything except for the note content for zen mode
|
||||
const toggleZenMode = () => {
|
||||
if (!zenModeActive) {
|
||||
$(".hide-in-zen-mode,.gutter").addClass("hidden-by-zen-mode");
|
||||
$("#container").addClass("zen-mode");
|
||||
zenModeActive = true;
|
||||
}
|
||||
else {
|
||||
// not hiding / showing explicitly since element might be hidden also for other reasons
|
||||
$(".hide-in-zen-mode,.gutter").removeClass("hidden-by-zen-mode");
|
||||
$("#container").removeClass("zen-mode");
|
||||
zenModeActive = false;
|
||||
}
|
||||
};
|
||||
|
||||
this.$widget.find(".toggle-zen-mode-button").on('click', toggleZenMode);
|
||||
keyboardActionService.setGlobalActionHandler("ToggleZenMode", toggleZenMode);
|
||||
|
||||
this.$widget.find(".reload-frontend-button").on('click', utils.reloadApp);
|
||||
keyboardActionService.setGlobalActionHandler("ReloadFrontendApp", utils.reloadApp);
|
||||
|
||||
this.$widget.find(".open-dev-tools-button").toggle(utils.isElectron());
|
||||
|
||||
const showOptionsDialog = () => import(OPTIONS).then(d => d.showDialog());
|
||||
this.$widget.find(".options-button").on('click', showOptionsDialog);
|
||||
keyboardActionService.setGlobalActionHandler("ShowOptions", showOptionsDialog);
|
||||
|
||||
const showHelpDialog = () => import(HELP).then(d => d.showDialog());
|
||||
this.$widget.find(".show-help-button").on('click', showHelpDialog);
|
||||
keyboardActionService.setGlobalActionHandler("ShowHelp", showHelpDialog);
|
||||
|
||||
const showSqlConsoleDialog = () => import(SQL_CONSOLE).then(d => d.showDialog());
|
||||
this.$widget.find(".open-sql-console-button").on('click', showSqlConsoleDialog);
|
||||
keyboardActionService.setGlobalActionHandler("ShowSQLConsole", showSqlConsoleDialog);
|
||||
|
||||
const showBackendLogDialog = () => import(BACKEND_LOG).then(d => d.showDialog());
|
||||
this.$widget.find(".show-backend-log-button").on('click', showBackendLogDialog);
|
||||
keyboardActionService.setGlobalActionHandler("ShowBackendLog", showBackendLogDialog);
|
||||
|
||||
this.$widget.find(".show-about-dialog-button").on('click', () => import(ABOUT).then(d => d.showDialog()));
|
||||
this.$widget.find(".show-about-dialog-button").on('click',
|
||||
() => import("../dialogs/about.js").then(d => d.showDialog()));
|
||||
|
||||
this.$widget.find(".sync-now-button").on('click', () => syncService.syncNow());
|
||||
|
||||
if (utils.isElectron()) {
|
||||
const toggleFullscreen = () => {
|
||||
const win = require('electron').remote.getCurrentWindow();
|
||||
this.$widget.find(".logout-button").toggle(!utils.isElectron());
|
||||
|
||||
if (win.isFullScreenable()) {
|
||||
win.setFullScreen(!win.isFullScreen());
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
|
||||
this.$widget.find(".toggle-fullscreen-button").on('click', toggleFullscreen);
|
||||
|
||||
keyboardActionService.setGlobalActionHandler("ToggleFullscreen", toggleFullscreen);
|
||||
}
|
||||
else {
|
||||
// outside of electron this is handled by the browser
|
||||
this.$widget.find(".toggle-fullscreen-button").hide();
|
||||
}
|
||||
|
||||
this.$widget.find(".logout-button")
|
||||
.toggle(!utils.isElectron())
|
||||
.on('click', () => {
|
||||
const $logoutForm = $('<form action="logout" method="POST">')
|
||||
.append($(`<input type="hidden" name="_csrf" value="${glob.csrfToken}"/>`));
|
||||
|
||||
$("body").append($logoutForm);
|
||||
$logoutForm.trigger('submit');
|
||||
});
|
||||
this.$widget.find(".open-dev-tools-button").toggle(utils.isElectron());
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
|
@ -10,9 +10,9 @@ const TPL = `
|
||||
}
|
||||
</style>
|
||||
|
||||
<a title="Go to previous note." class="history-back-button icon-action bx bx-left-arrow-circle"></a>
|
||||
<a title="Go to previous note." data-trigger-event="backInNoteHistory" class="icon-action bx bx-left-arrow-circle"></a>
|
||||
|
||||
<a title="Go to next note." class="history-forward-button icon-action bx bx-right-arrow-circle"></a>
|
||||
<a title="Go to next note." data-trigger-event="forwardInNoteHistory" class="icon-action bx bx-right-arrow-circle"></a>
|
||||
</div>
|
||||
`;
|
||||
|
||||
@ -24,13 +24,6 @@ export default class HistoryNavigationWidget extends BasicWidget {
|
||||
|
||||
this.$widget = $(TPL);
|
||||
|
||||
this.$widget.find(".history-back-button").on('click', window.history.back);
|
||||
this.$widget.find(".history-forward-button").on('click', window.history.forward);
|
||||
|
||||
// FIXME: does not belong here
|
||||
keyboardActionService.setGlobalActionHandler("BackInNoteHistory", window.history.back);
|
||||
keyboardActionService.setGlobalActionHandler("ForwardInNoteHistory", window.history.forward);
|
||||
|
||||
return this.$widget;
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user