mirror of
https://github.com/zadam/trilium.git
synced 2025-11-07 13:56:11 +01:00
keyboard shortcuts options pane
This commit is contained in:
@@ -22,6 +22,7 @@ export async function showDialog() {
|
||||
import('./options/other.js'),
|
||||
import('./options/sidebar.js'),
|
||||
import('./options/sync.js'),
|
||||
import('./options/keyboard_shortcuts.js'),
|
||||
]))
|
||||
.map(m => new m.default)
|
||||
.forEach(tab => {
|
||||
|
||||
@@ -3,19 +3,19 @@ import toastService from "../../services/toast.js";
|
||||
|
||||
const TPL = `
|
||||
<h4 style="margin-top: 0;">Sync</h4>
|
||||
<button id="force-full-sync-button" class="btn btn-secondary">Force full sync</button>
|
||||
<button id="force-full-sync-button" class="btn">Force full sync</button>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<button id="fill-sync-rows-button" class="btn btn-secondary">Fill sync rows</button>
|
||||
<button id="fill-sync-rows-button" class="btn">Fill sync rows</button>
|
||||
|
||||
<br/>
|
||||
<br/>
|
||||
|
||||
<h4>Debugging</h4>
|
||||
|
||||
<button id="anonymize-button" class="btn btn-secondary">Save anonymized database</button><br/><br/>
|
||||
<button id="anonymize-button" class="btn">Save anonymized database</button><br/><br/>
|
||||
|
||||
<p>This action will create a new copy of the database and anonymise it (remove all note content and leave only structure and metadata)
|
||||
for sharing online for debugging purposes without fear of leaking your personal data.</p>
|
||||
@@ -24,7 +24,7 @@ const TPL = `
|
||||
|
||||
<p>This will rebuild database which will typically result in smaller database file. No data will be actually changed.</p>
|
||||
|
||||
<button id="vacuum-database-button" class="btn btn-secondary">Vacuum database</button>`;
|
||||
<button id="vacuum-database-button" class="btn">Vacuum database</button>`;
|
||||
|
||||
export default class AdvancedOptions {
|
||||
constructor() {
|
||||
|
||||
61
src/public/javascripts/dialogs/options/keyboard_shortcuts.js
Normal file
61
src/public/javascripts/dialogs/options/keyboard_shortcuts.js
Normal file
@@ -0,0 +1,61 @@
|
||||
import server from "../../services/server.js";
|
||||
import optionsService from "../../services/options.js";
|
||||
|
||||
const TPL = `
|
||||
<h4>Keyboard shortcuts</h4>
|
||||
|
||||
<div style="overflow: auto; height: 500px;">
|
||||
<table id="keyboard-shortcut-table" cellpadding="10">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>Action name</th>
|
||||
<th>Shortcuts</th>
|
||||
<th>Default shortcuts</th>
|
||||
<th>Description</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody></tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div style="display: flex; justify-content: space-between">
|
||||
<button class="btn btn-primary">Reload app to apply changes</button>
|
||||
|
||||
<button class="btn">Set all shortcuts to the default</button>
|
||||
</div>
|
||||
`;
|
||||
|
||||
export default class KeyboardShortcutsOptions {
|
||||
constructor() {
|
||||
$("#options-keyboard-shortcuts").html(TPL);
|
||||
|
||||
const $table = $("#keyboard-shortcut-table tbody");
|
||||
|
||||
server.get('keyboard-actions').then(actions => {
|
||||
for (const action of actions) {
|
||||
const $tr = $("<tr>")
|
||||
.append($("<td>").text(action.actionName))
|
||||
.append($("<td>").append(
|
||||
$(`<input type="text" class="form-control">`).val(action.effectiveShortcuts.join(", ")))
|
||||
)
|
||||
.append($("<td>").text(action.defaultShortcuts.join(", ")))
|
||||
.append($("<td>").text(action.description));
|
||||
|
||||
$table.append($tr);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async save() {
|
||||
const enabledMimeTypes = [];
|
||||
|
||||
this.$mimeTypes.find("input:checked").each(
|
||||
(i, el) => enabledMimeTypes.push($(el).attr("data-mime-type")));
|
||||
|
||||
const opts = { codeNotesMimeTypes: JSON.stringify(enabledMimeTypes) };
|
||||
|
||||
await server.put('options', opts);
|
||||
|
||||
await optionsService.reloadOptions();
|
||||
}
|
||||
}
|
||||
@@ -25,7 +25,7 @@ const TPL = `
|
||||
<div style="display: flex; justify-content: space-between;">
|
||||
<button class="btn btn-primary">Save</button>
|
||||
|
||||
<button class="btn btn-secondary" type="button" data-help-page="Synchronization">Help</button>
|
||||
<button class="btn" type="button" data-help-page="Synchronization">Help</button>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -35,7 +35,7 @@ const TPL = `
|
||||
|
||||
<p>This will test connection and handshake to the sync server. If sync server isn't initialized, this will set it up to sync with local document.</p>
|
||||
|
||||
<button id="test-sync-button" class="btn btn-secondary">Test sync</button>`;
|
||||
<button id="test-sync-button" class="btn">Test sync</button>`;
|
||||
|
||||
export default class SyncOptions {
|
||||
constructor() {
|
||||
|
||||
@@ -419,7 +419,17 @@ div.ui-tooltip {
|
||||
border-radius: var(--button-border-radius);
|
||||
}
|
||||
|
||||
.btn:not(.btn-primary):not(.btn-secondary):not(.btn-danger) {
|
||||
.btn.btn-primary {
|
||||
border-color: var(--primary-button-border-color);
|
||||
background-color: var(--primary-button-background-color);
|
||||
color: var(--primary-button-text-color);
|
||||
}
|
||||
|
||||
.btn.btn-primary kbd {
|
||||
color: var(--primary-button-text-color);
|
||||
}
|
||||
|
||||
.btn:not(.btn-primary) {
|
||||
border-color: var(--button-border-color);
|
||||
background-color: var(--button-background-color);
|
||||
color: var(--button-text-color);
|
||||
|
||||
@@ -17,6 +17,9 @@
|
||||
--button-border-color: #ddd;
|
||||
--button-text-color: black;
|
||||
--button-border-radius: 5px;
|
||||
--primary-button-background-color: #6c757d;
|
||||
--primary-button-text-color: white;
|
||||
--primary-button-border-color: #6c757d;
|
||||
--muted-text-color: #666;
|
||||
--input-text-color: black;
|
||||
--input-background-color: white;
|
||||
@@ -44,6 +47,9 @@ body.theme-black {
|
||||
--button-border-color: #444;
|
||||
--button-text-color: white;
|
||||
--button-border-radius: 5px;
|
||||
--primary-button-background-color: #888;
|
||||
--primary-button-text-color: white;
|
||||
--primary-button-border-color: #999;
|
||||
--muted-text-color: #ccc;
|
||||
--input-text-color: white;
|
||||
--input-background-color: black;
|
||||
@@ -75,6 +81,9 @@ body.theme-dark {
|
||||
--button-border-color: #444;
|
||||
--button-text-color: white;
|
||||
--button-border-radius: 5px;
|
||||
--primary-button-background-color: #888;
|
||||
--primary-button-text-color: white;
|
||||
--primary-button-border-color: #999;
|
||||
--muted-text-color: #ccc;
|
||||
--input-text-color: white;
|
||||
--input-background-color: #333;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
"use strict";
|
||||
|
||||
const optionService = require('./options');
|
||||
const utils = require('./utils');
|
||||
const log = require('./log');
|
||||
|
||||
const ELECTRON = "electron";
|
||||
@@ -9,52 +8,52 @@ const ELECTRON = "electron";
|
||||
const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
{
|
||||
actionName: "JumpToNote",
|
||||
defaultShortcuts: ["mod+j"],
|
||||
defaultShortcuts: ["Mod+J"],
|
||||
description: 'Open "Jump to note" dialog'
|
||||
},
|
||||
{
|
||||
actionName: "MarkdownToHTML",
|
||||
defaultShortcuts: ["mod+return"]
|
||||
defaultShortcuts: ["Mod+Return"]
|
||||
},
|
||||
{
|
||||
actionName: "NewTab",
|
||||
defaultShortcuts: ["mod+t"],
|
||||
defaultShortcuts: ["Mod+T"],
|
||||
only: ELECTRON
|
||||
},
|
||||
{
|
||||
actionName: "CloseTab",
|
||||
defaultShortcuts: ["mod+w"],
|
||||
defaultShortcuts: ["Mod+W"],
|
||||
only: ELECTRON
|
||||
},
|
||||
{
|
||||
actionName: "NextTab",
|
||||
defaultShortcuts: ["mod+tab"],
|
||||
defaultShortcuts: ["Mod+Tab"],
|
||||
only: ELECTRON
|
||||
},
|
||||
{
|
||||
actionName: "PreviousTab",
|
||||
defaultShortcuts: ["mod+shift+tab"],
|
||||
defaultShortcuts: ["Mod+SHIFT+Tab"],
|
||||
only: ELECTRON
|
||||
},
|
||||
{
|
||||
actionName: "CreateNoteAfter",
|
||||
defaultShortcuts: ["mod+o"]
|
||||
defaultShortcuts: ["Mod+O"]
|
||||
},
|
||||
{
|
||||
actionName: "CreateNoteInto",
|
||||
defaultShortcuts: ["mod+p"]
|
||||
defaultShortcuts: ["Mod+P"]
|
||||
},
|
||||
{
|
||||
actionName: "ScrollToActiveNote",
|
||||
defaultShortcuts: ["mod+."]
|
||||
defaultShortcuts: ["Mod+."]
|
||||
},
|
||||
{
|
||||
actionName: "CollapseTree",
|
||||
defaultShortcuts: ["alt+c"]
|
||||
defaultShortcuts: ["Alt+C"]
|
||||
},
|
||||
{
|
||||
actionName: "RunSQL",
|
||||
defaultShortcuts: ["mod+return"]
|
||||
defaultShortcuts: ["Mod+return"]
|
||||
},
|
||||
{
|
||||
actionName: "FocusNote",
|
||||
@@ -62,51 +61,51 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
},
|
||||
{
|
||||
actionName: "RunCurrentNote",
|
||||
defaultShortcuts: ["mod+return"]
|
||||
defaultShortcuts: ["Mod+return"]
|
||||
},
|
||||
{
|
||||
actionName: "ClipboardCopy",
|
||||
defaultShortcuts: ["mod+c"]
|
||||
defaultShortcuts: ["Mod+C"]
|
||||
},
|
||||
{
|
||||
actionName: "ClipboardPaste",
|
||||
defaultShortcuts: ["mod+v"]
|
||||
defaultShortcuts: ["Mod+V"]
|
||||
},
|
||||
{
|
||||
actionName: "ClipboardCut",
|
||||
defaultShortcuts: ["mod+x"]
|
||||
defaultShortcuts: ["Mod+X"]
|
||||
},
|
||||
{
|
||||
actionName: "SelectAllNotesInParent",
|
||||
defaultShortcuts: ["mod+a"]
|
||||
defaultShortcuts: ["Mod+A"]
|
||||
},
|
||||
{
|
||||
actionName: "Undo",
|
||||
defaultShortcuts: ["mod+z"]
|
||||
defaultShortcuts: ["Mod+Z"]
|
||||
},
|
||||
{
|
||||
actionName: "Redo",
|
||||
defaultShortcuts: ["mod+y"]
|
||||
defaultShortcuts: ["Mod+Y"]
|
||||
},
|
||||
{
|
||||
actionName: "AddLinkToText",
|
||||
defaultShortcuts: ["mod+l"]
|
||||
defaultShortcuts: ["Mod+L"]
|
||||
},
|
||||
{
|
||||
actionName: "CloneNotesTo",
|
||||
defaultShortcuts: ["mod+shift+c"]
|
||||
defaultShortcuts: ["Mod+Shift+C"]
|
||||
},
|
||||
{
|
||||
actionName: "MoveNotesTo",
|
||||
defaultShortcuts: ["mod+shift+c"]
|
||||
defaultShortcuts: ["Mod+Shift+C"]
|
||||
},
|
||||
{
|
||||
actionName: "SearchNotes",
|
||||
defaultShortcuts: ["mod+s"]
|
||||
defaultShortcuts: ["Mod+S"]
|
||||
},
|
||||
{
|
||||
actionName: "ShowAttributes",
|
||||
defaultShortcuts: ["alt+a"]
|
||||
defaultShortcuts: ["Alt+A"]
|
||||
},
|
||||
{
|
||||
actionName: "ShowNoteInfo",
|
||||
@@ -134,58 +133,67 @@ const DEFAULT_KEYBOARD_ACTIONS = [
|
||||
},
|
||||
{
|
||||
actionName: "ShowHelp",
|
||||
defaultShortcuts: ["f1"]
|
||||
defaultShortcuts: ["F1"]
|
||||
},
|
||||
{
|
||||
actionName: "ShowSQLConsole",
|
||||
defaultShortcuts: ["alt+o"]
|
||||
defaultShortcuts: ["Alt+O"]
|
||||
},
|
||||
{
|
||||
actionName: "BackInNoteHistory",
|
||||
defaultShortcuts: ["alt+left"]
|
||||
defaultShortcuts: ["Alt+Left"]
|
||||
},
|
||||
{
|
||||
actionName: "ForwardInNoteHistory",
|
||||
defaultShortcuts: ["alt+right"]
|
||||
defaultShortcuts: ["Alt+Right"]
|
||||
},
|
||||
{
|
||||
actionName: "ToggleZenMode",
|
||||
defaultShortcuts: ["alt+m"]
|
||||
defaultShortcuts: ["Alt+M"]
|
||||
},
|
||||
{
|
||||
actionName: "InsertDateTime",
|
||||
defaultShortcuts: ["alt+t"]
|
||||
defaultShortcuts: ["Alt+T"]
|
||||
},
|
||||
{
|
||||
actionName: "ReloadApp",
|
||||
defaultShortcuts: ["f5", "mod+r"]
|
||||
defaultShortcuts: ["F5", "Mod+R"]
|
||||
},
|
||||
{
|
||||
actionName: "OpenDevTools",
|
||||
defaultShortcuts: ["mod+shift+i"]
|
||||
defaultShortcuts: ["Mod+SHIFT+I"]
|
||||
},
|
||||
{
|
||||
actionName: "FindInText",
|
||||
defaultShortcuts: ["mod+f"]
|
||||
defaultShortcuts: ["Mod+F"]
|
||||
},
|
||||
{
|
||||
actionName: "ToggleFullscreen",
|
||||
defaultShortcuts: ["f11"]
|
||||
defaultShortcuts: ["F11"]
|
||||
},
|
||||
{
|
||||
actionName: "ZoomOut",
|
||||
defaultShortcuts: ["mod+-"]
|
||||
defaultShortcuts: ["Mod+-"]
|
||||
},
|
||||
{
|
||||
actionName: "ZoomIn",
|
||||
defaultShortcuts: ["mod+="]
|
||||
defaultShortcuts: ["Mod+="]
|
||||
}
|
||||
];
|
||||
|
||||
if (process.platform === "darwin") {
|
||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Meta"));
|
||||
}
|
||||
|
||||
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'BackInNoteHistory').defaultShortcuts = ["meta+left"];
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'ForwardInNoteHistory').defaultShortcuts = ["meta+right"];
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'BackInNoteHistory').defaultShortcuts = ["Meta+Left"];
|
||||
DEFAULT_KEYBOARD_ACTIONS.find(ka => ka.actionName === 'ForwardInNoteHistory').defaultShortcuts = ["Meta+Right"];
|
||||
}
|
||||
else {
|
||||
for (const action of DEFAULT_KEYBOARD_ACTIONS) {
|
||||
action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("Mod", "Ctrl"));
|
||||
}
|
||||
}
|
||||
|
||||
async function getKeyboardActions() {
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
<div id="confirm-dialog-custom"></div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button class="btn btn-secondary btn-sm" id="confirm-dialog-cancel-button">Cancel</button>
|
||||
<button class="btn btn-sm" id="confirm-dialog-cancel-button">Cancel</button>
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#options-sidebar">Sidebar</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#options-keyboard-shortcuts">Keyboard shortcuts</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link" data-toggle="tab" href="#options-code-notes">Code notes</a>
|
||||
</li>
|
||||
@@ -36,6 +39,7 @@
|
||||
<div class="tab-content">
|
||||
<div id="options-appearance" class="tab-pane active"></div>
|
||||
<div id="options-sidebar" class="tab-pane"></div>
|
||||
<div id="options-keyboard-shortcuts" class="tab-pane"></div>
|
||||
<div id="options-code-notes" class="tab-pane"></div>
|
||||
<div id="options-change-password" class="tab-pane"></div>
|
||||
<div id="options-other" class="tab-pane"></div>
|
||||
|
||||
Reference in New Issue
Block a user