refactored KB handling and add link dialog

This commit is contained in:
zadam 2020-02-15 22:12:05 +01:00
parent b2a48a1f3a
commit 7e41a2750c
14 changed files with 211 additions and 160 deletions

View file

@ -9,14 +9,13 @@ const $autoComplete = $("#add-link-note-autocomplete");
const $linkTitle = $("#link-title");
const $addLinkTitleFormGroup = $("#add-link-title-form-group");
export async function showDialog() {
appContext.trigger('executeInActiveEditor', {
callback: textEditor => {
const hasSelection = !textEditor.model.document.selection.isCollapsed;
/** @var TextTypeWidget */
let textTypeWidget;
$addLinkTitleFormGroup.toggle(!hasSelection);
}
});
export async function showDialog(widget) {
textTypeWidget = widget;
$addLinkTitleFormGroup.toggle(!textTypeWidget.hasSelection());
utils.openDialog($dialog);
@ -58,10 +57,7 @@ $form.on('submit', () => {
if (notePath) {
$dialog.modal('hide');
appContext.trigger(`addLinkToActiveEditor`, {
linkTitle: $linkTitle.val(),
linkHref: '#' + notePath
});
textTypeWidget.addLink($linkTitle.val(), '#' + notePath);
}
else {
console.error("No path to add link.");

View file

@ -42,10 +42,6 @@ export default class DialogCommandExecutor extends Component {
}
}
addLinkToTextCommand() {
import("../dialogs/add_link.js").then(d => d.showDialog());
}
async cloneNoteIdsToCommand({noteIds}) {
const d = await import("../dialogs/clone_to.js");
d.showDialog(noteIds);

View file

@ -5,18 +5,39 @@ import appContext from "./app_context.js";
const keyboardActionRepo = {};
const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
actions = actions.filter(a => !!a.actionName); // filter out separators
for (const action of actions) {
action.effectiveShortcuts = action.effectiveShortcuts.filter(shortcut => !shortcut.startsWith("global:"));
action.actionName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1);
keyboardActionRepo[action.actionName] = action;
}
for (const shortcut of action.effectiveShortcuts || []) {
if (shortcut && !shortcut.startsWith("global:")) { // global shortcuts should be handled in the electron code
const eventName = action.actionName.charAt(0).toLowerCase() + action.actionName.slice(1);
return actions;
});
if (action.scope !== 'note-tree') {
// empty object param so that destructuring with optional params work
utils.bindGlobalShortcut(shortcut, () => appContext.trigger(eventName, {}));
}
}
async function getActionsForScope(scope) {
const actions = await keyboardActionsLoaded;
return actions.filter(action => action.scope === scope);
}
async function setupActionsForElement(scope, $el, component) {
const actions = await getActionsForScope(scope);
for (const action of actions) {
for (const shortcut of action.effectiveShortcuts) {
utils.bindElShortcut($el, shortcut, () => component.triggerCommand(action.actionName));
}
}
}
getActionsForScope("window").then(actions => {
for (const action of actions) {
for (const shortcut of action.effectiveShortcuts) {
// empty object param so that destructuring with optional params work
utils.bindGlobalShortcut(shortcut, () => appContext.trigger(action.actionName, {}));
}
}
});
@ -24,8 +45,6 @@ const keyboardActionsLoaded = server.get('keyboard-actions').then(actions => {
server.get('keyboard-shortcuts-for-notes').then(shortcutForNotes => {
for (const shortcut in shortcutForNotes) {
utils.bindGlobalShortcut(shortcut, async () => {
const treeService = (await import("./tree.js")).default;
appContext.tabManager.getActiveTabContext().setNote(shortcutForNotes[shortcut]);
});
}
@ -104,5 +123,7 @@ export default {
setElementActionHandler,
triggerAction,
getAction,
updateDisplayedShortcuts
updateDisplayedShortcuts,
getActionsForScope,
setupActionsForElement
};

View file

@ -51,39 +51,39 @@ class TreeContextMenu {
return [
{ title: 'Open in new tab', cmd: "openInTab", uiIcon: "empty", enabled: noSelectedNotes },
{ title: 'Insert note after <kbd data-kb-action="CreateNoteAfter"></kbd>', cmd: "insertNoteAfter", uiIcon: "plus",
{ title: 'Insert note after <kbd data-kb-action="createNoteAfter"></kbd>', cmd: "insertNoteAfter", uiIcon: "plus",
items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null,
enabled: insertNoteAfterEnabled && noSelectedNotes },
{ title: 'Insert child note <kbd data-kb-action="CreateNoteInto"></kbd>', cmd: "insertChildNote", uiIcon: "plus",
{ title: 'Insert child note <kbd data-kb-action="createNoteInto"></kbd>', cmd: "insertChildNote", uiIcon: "plus",
items: notSearch ? this.getNoteTypeItems("insertChildNote") : null,
enabled: notSearch && noSelectedNotes },
{ title: 'Delete <kbd data-kb-action="DeleteNotes"></kbd>', cmd: "delete", uiIcon: "trash",
{ title: 'Delete <kbd data-kb-action="deleteNotes"></kbd>', cmd: "delete", uiIcon: "trash",
enabled: isNotRoot && !isHoisted && parentNotSearch },
{ title: "----" },
{ title: 'Search in subtree <kbd data-kb-action="SearchInSubtree"></kbd>', cmd: "searchInSubtree", uiIcon: "search",
{ title: 'Search in subtree <kbd data-kb-action="searchInSubtree"></kbd>', cmd: "searchInSubtree", uiIcon: "search",
enabled: notSearch && noSelectedNotes },
isHoisted ? null : { title: 'Hoist note <kbd data-kb-action="ToggleNoteHoisting"></kbd>', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
isHoisted ? null : { title: 'Hoist note <kbd data-kb-action="toggleNoteHoisting"></kbd>', cmd: "hoist", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
!isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-kb-action="ToggleNoteHoisting"></kbd>', cmd: "unhoist", uiIcon: "arrow-up" },
{ title: 'Edit branch prefix <kbd data-kb-action="EditBranchPrefix"></kbd>', cmd: "editBranchPrefix", uiIcon: "empty",
{ title: 'Edit branch prefix <kbd data-kb-action="editBranchPrefix"></kbd>', cmd: "editBranchPrefix", uiIcon: "empty",
enabled: isNotRoot && parentNotSearch && noSelectedNotes},
{ title: "Advanced", uiIcon: "empty", enabled: true, items: [
{ title: 'Collapse subtree <kbd data-kb-action="CollapseSubtree"></kbd>', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes },
{ title: 'Collapse subtree <kbd data-kb-action="collapseSubtree"></kbd>', cmd: "collapseSubtree", uiIcon: "align-justify", enabled: noSelectedNotes },
{ title: "Force note sync", cmd: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes },
{ title: 'Sort alphabetically <kbd data-kb-action="SortChildNotes"></kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }
{ title: 'Sort alphabetically <kbd data-kb-action="sortChildNotes"></kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }
] },
{ title: "----" },
{ title: "Protect subtree", cmd: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes },
{ title: "Unprotect subtree", cmd: "unprotectSubtree", uiIcon: "shield", enabled: noSelectedNotes },
{ title: "----" },
{ title: 'Copy / clone <kbd data-kb-action="CopyNotesToClipboard"></kbd>', cmd: "copy", uiIcon: "copy",
{ title: 'Copy / clone <kbd data-kb-action="copyNotesToClipboard"></kbd>', cmd: "copy", uiIcon: "copy",
enabled: isNotRoot && !isHoisted },
{ title: 'Clone to ... <kbd data-kb-action="CloneNotesTo"></kbd>', cmd: "cloneTo", uiIcon: "empty",
{ title: 'Clone to ... <kbd data-kb-action="cloneNotesTo"></kbd>', cmd: "cloneTo", uiIcon: "empty",
enabled: isNotRoot && !isHoisted },
{ title: 'Cut <kbd data-kb-action="CutNotesToClipboard"></kbd>', cmd: "cut", uiIcon: "cut",
{ title: 'Cut <kbd data-kb-action="cutNotesToClipboard"></kbd>', cmd: "cut", uiIcon: "cut",
enabled: isNotRoot && !isHoisted && parentNotSearch },
{ title: 'Move to ... <kbd data-kb-action="MoveNotesTo"></kbd>', cmd: "moveTo", uiIcon: "empty",
{ title: 'Move to ... <kbd data-kb-action="moveNotesTo"></kbd>', cmd: "moveTo", uiIcon: "empty",
enabled: isNotRoot && !isHoisted && parentNotSearch },
{ title: 'Paste into <kbd data-kb-action="PasteNotesFromClipboard"></kbd>', cmd: "pasteInto", uiIcon: "paste",
{ title: 'Paste into <kbd data-kb-action="pasteNotesFromClipboard"></kbd>', cmd: "pasteInto", uiIcon: "paste",
enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes },
{ title: 'Paste after', cmd: "pasteAfter", uiIcon: "paste",
enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes },

View file

@ -52,12 +52,12 @@ function getSelectedOrActiveBranchIds(treeWidget, node) {
*/
function getTemplates(treeWidget) {
return {
"DeleteNotes": node => {
"deleteNotes": node => {
const branchIds = getSelectedOrActiveBranchIds(treeWidget, node);
treeChangesService.deleteNotes(treeWidget, branchIds);
},
"MoveNoteUp": node => {
"moveNoteUp": node => {
const beforeNode = node.getPrevSibling();
if (beforeNode !== null) {
@ -66,7 +66,7 @@ function getTemplates(treeWidget) {
return false;
},
"MoveNoteDown": node => {
"moveNoteDown": node => {
const afterNode = node.getNextSibling();
if (afterNode !== null) {
treeChangesService.moveAfterBranch([node.data.branchId], afterNode.data.branchId);
@ -74,12 +74,12 @@ function getTemplates(treeWidget) {
return false;
},
"MoveNoteUpInHierarchy": node => {
"moveNoteUpInHierarchy": node => {
treeChangesService.moveNodeUpInHierarchy(node);
return false;
},
"MoveNoteDownInHierarchy": node => {
"moveNoteDownInHierarchy": node => {
const toNode = node.getPrevSibling();
if (toNode !== null) {
@ -88,7 +88,7 @@ function getTemplates(treeWidget) {
return false;
},
"AddNoteAboveToSelection": () => {
"addNoteAboveToSelection": () => {
const node = treeWidget.getFocusedNode();
if (!node) {
@ -113,7 +113,7 @@ function getTemplates(treeWidget) {
return false;
},
"AddNoteBelowToSelection": () => {
"addNoteBelowToSelection": () => {
const node = treeWidget.getFocusedNode();
if (!node) {
@ -138,42 +138,42 @@ function getTemplates(treeWidget) {
return false;
},
"CollapseSubtree": node => {
"collapseSubtree": node => {
treeWidget.collapseTree(node);
},
"SortChildNotes": node => {
"sortChildNotes": node => {
treeService.sortAlphabetically(node.data.noteId);
return false;
},
"SelectAllNotesInParent": node => {
"selectAllNotesInParent": node => {
for (const child of node.getParent().getChildren()) {
child.setSelected(true);
}
return false;
},
"CopyNotesToClipboard": node => {
"copyNotesToClipboard": node => {
clipboard.copy(getSelectedOrActiveBranchIds(treeWidget, node));
return false;
},
"CutNotesToClipboard": node => {
"cutNotesToClipboard": node => {
clipboard.cut(getSelectedOrActiveBranchIds(treeWidget, node));
return false;
},
"PasteNotesFromClipboard": node => {
"pasteNotesFromClipboard": node => {
clipboard.pasteInto(node.data.noteId);
return false;
},
"EditNoteTitle": node => {
"editNoteTitle": node => {
appContext.trigger('focusOnTitle');
return false;
},
"ActivateParentNote": node => {
"activateParentNote": node => {
if (!hoistedNoteService.isRootNode(node)) {
node.getParent().setActive().then(treeWidget.clearSelectedNodes);
}

View file

@ -19,17 +19,17 @@ const WIDGET_TPL = `
<a data-trigger-event="collapseTree"
title="Collapse note tree"
data-kb-action="CollapseTree"
data-kb-action="collapseTree"
class="icon-action bx bx-layer-minus"></a>
<a data-trigger-event="scrollToActiveNote"
title="Scroll to active note"
data-kb-action="ScrollToActiveNote"
data-kb-action="scrollToActiveNote"
class="icon-action bx bx-crosshair"></a>
<a data-trigger-event="searchNotes"
title="Search in notes"
data-kb-action="SearchNotes"
data-kb-action="searchNotes"
class="icon-action bx bx-search"></a>
</div>
`;

View file

@ -42,44 +42,44 @@ const TPL = `
<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>
<kbd data-kb-action="openDevTools"></kbd>
</a>
<a class="dropdown-item" data-trigger-event="showSQLConsole">
<span class="bx bx-data"></span>
Open SQL Console
<kbd data-kb-action="ShowSQLConsole"></kbd>
<kbd data-kb-action="showSQLConsole"></kbd>
</a>
<a class="dropdown-item" data-trigger-event="showBackendLog">
<span class="bx bx-empty"></span>
Show backend log
<kbd data-kb-action="ShowBackendLog"></kbd>
<kbd data-kb-action="showBackendLog"></kbd>
</a>
<a class="dropdown-item" 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>
<kbd data-kb-action="reloadFrontendApp"></kbd>
</a>
<a class="dropdown-item" data-trigger-event="toggleZenMode">
<span class="bx bx-empty"></span>
Toggle Zen mode
<kbd data-kb-action="ToggleZenMode"></kbd>
<kbd data-kb-action="toggleZenMode"></kbd>
</a>
<a class="dropdown-item" data-trigger-event="toggleFullscreen">
<span class="bx bx-empty"></span>
Toggle fullscreen
<kbd data-kb-action="ToggleFullscreen"></kbd>
<kbd data-kb-action="toggleFullscreen"></kbd>
</a>
<a class="dropdown-item" data-trigger-event="showHelp">
<span class="bx bx-info-circle"></span>
Show Help
<kbd data-kb-action="ShowHelp"></kbd>
<kbd data-kb-action="showHelp"></kbd>
</a>
<a class="dropdown-item show-about-dialog-button">

View file

@ -8,13 +8,13 @@ const TPL = `
</button>
<div class="dropdown-menu dropdown-menu-right">
<a data-trigger-event="showNoteRevisions" class="dropdown-item show-note-revisions-button">Revisions</a>
<a data-trigger-event="showAttributes" class="dropdown-item show-attributes-button"><kbd data-kb-action="ShowAttributes"></kbd> Attributes</a>
<a data-trigger-event="showLinkMap" class="dropdown-item show-link-map-button"><kbd data-kb-action="ShowLinkMap"></kbd> Link map</a>
<a data-trigger-event="showNoteSource" class="dropdown-item show-source-button"><kbd data-kb-action="ShowNoteSource"></kbd> Note source</a>
<a data-trigger-event="showAttributes" class="dropdown-item show-attributes-button"><kbd data-kb-action="showAttributes"></kbd> Attributes</a>
<a data-trigger-event="showLinkMap" class="dropdown-item show-link-map-button"><kbd data-kb-action="showLinkMap"></kbd> Link map</a>
<a data-trigger-event="showNoteSource" class="dropdown-item show-source-button"><kbd data-kb-action="showNoteSource"></kbd> Note source</a>
<a class="dropdown-item import-files-button">Import files</a>
<a class="dropdown-item export-note-button">Export note</a>
<a data-trigger-event="printActiveNote" class="dropdown-item print-note-button"><kbd data-kb-action="PrintActiveNote"></kbd> Print note</a>
<a data-trigger-event="showNoteInfo" class="dropdown-item show-note-info-button"><kbd data-kb-action="ShowNoteInfo"></kbd> Note info</a>
<a data-trigger-event="printActiveNote" class="dropdown-item print-note-button"><kbd data-kb-action="printActiveNote"></kbd> Print note</a>
<a data-trigger-event="showNoteInfo" class="dropdown-item show-note-info-button"><kbd data-kb-action="showNoteInfo"></kbd> Note info</a>
</div>
</div>`;

View file

@ -98,7 +98,7 @@ export default class NoteDetailWidget extends TabAwareWidget {
if (!(this.type in this.typeWidgets)) {
const clazz = typeWidgetClasses[this.type];
const typeWidget = this.typeWidgets[this.type] = new clazz(this.appContext);
const typeWidget = this.typeWidgets[this.type] = new clazz(this.appContext, this);
typeWidget.spacedUpdate = this.spacedUpdate;
this.children.push(typeWidget);

View file

@ -32,12 +32,12 @@ const TPL = `
</style>
<div style="flex-grow: 100; display: flex;">
<button class="btn btn-sm jump-to-note-dialog-button" data-kb-action="JumpToNote">
<button class="btn btn-sm jump-to-note-dialog-button" data-kb-action="jumpToNote">
<span class="bx bx-crosshair"></span>
Jump to note
</button>
<button class="btn btn-sm recent-changes-button" data-kb-action="ShowRecentChanges">
<button class="btn btn-sm recent-changes-button" data-kb-action="showRecentChanges">
<span class="bx bx-history"></span>
Recent changes

View file

@ -28,11 +28,11 @@ const TAB_TPL = `
<div class="note-tab-wrapper">
<div class="note-tab-title"></div>
<div class="note-tab-drag-handle"></div>
<div class="note-tab-close kb-in-title" title="Close tab" data-kb-action="CloseActiveTab"><span>×</span></div>
<div class="note-tab-close kb-in-title" title="Close tab" data-kb-action="closeActiveTab"><span>×</span></div>
</div>
</div>`;
const NEW_TAB_BUTTON_TPL = `<div class="note-new-tab kb-in-title" data-kb-action="OpenNewTab" title="Add new tab">+</div>`;
const NEW_TAB_BUTTON_TPL = `<div class="note-new-tab kb-in-title" data-kb-action="openNewTab" title="Add new tab">+</div>`;
const FILLER_TPL = `<div class="tab-row-filler">
<div class="tab-row-border"></div>
</div>`;

View file

@ -4,6 +4,7 @@ import mimeTypesService from '../../services/mime_types.js';
import TypeWidget from "./type_widget.js";
import utils from "../../services/utils.js";
import appContext from "../../services/app_context.js";
import keyboardActionService from "../../services/keyboard_actions.js";
const ENABLE_INSPECTOR = false;
@ -99,6 +100,8 @@ export default class TextTypeWidget extends TypeWidget {
this.initialized = this.initEditor();
keyboardActionService.setupActionsForElement('text-detail', this.$widget, this);
return this.$widget;
}
@ -184,11 +187,7 @@ export default class TextTypeWidget extends TypeWidget {
this.$widget.scrollTop(0);
}
insertDateTimeToTextListener() {
if (!this.isActive()) {
return;
}
insertDateTimeToTextCommand() {
const date = new Date();
const dateString = utils.formatDateTime(date);
@ -221,11 +220,7 @@ export default class TextTypeWidget extends TypeWidget {
this.addTextToEditor(text);
}
async addLinkToActiveEditorListener({linkTitle, linkHref}) {
if (!this.isActive()) {
return;
}
async addLink(linkTitle, linkHref) {
await this.initialized;
if (this.hasSelection()) {
@ -255,4 +250,8 @@ export default class TextTypeWidget extends TypeWidget {
callback(this.textEditor);
}
addLinkToTextCommand() {
import("../../dialogs/add_link.js").then(d => d.showDialog(this));
}
}

View file

@ -14,25 +14,30 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "BackInNoteHistory",
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
defaultShortcuts: isMac ? ["Meta+Left"] : ["Alt+Left"]
defaultShortcuts: isMac ? ["Meta+Left"] : ["Alt+Left"],
scope: "window"
},
{
actionName: "ForwardInNoteHistory",
// Mac has a different history navigation shortcuts - https://github.com/zadam/trilium/issues/376
defaultShortcuts: isMac ? ["Meta+Right"] : ["Alt+Right"]
defaultShortcuts: isMac ? ["Meta+Right"] : ["Alt+Right"],
scope: "window"
},
{
actionName: "JumpToNote",
defaultShortcuts: ["CommandOrControl+J"],
description: 'Open "Jump to note" dialog'
description: 'Open "Jump to note" dialog',
scope: "window"
},
{
actionName: "ScrollToActiveNote",
defaultShortcuts: ["CommandOrControl+."]
defaultShortcuts: ["CommandOrControl+."],
scope: "window" // FIXME - how do we find what note tree should be updated?
},
{
actionName: "SearchNotes",
defaultShortcuts: ["CommandOrControl+S"]
defaultShortcuts: ["CommandOrControl+S"],
scope: "window"
},
{
actionName: "SearchInSubtree",
@ -43,6 +48,7 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "CollapseTree",
defaultShortcuts: ["Alt+C"],
scope: "note-tree"
},
{
actionName: "CollapseSubtree",
@ -69,16 +75,19 @@ const DEFAULT_KEYBOARD_ACTIONS = [
},
{
actionName: "CreateNoteAfter",
defaultShortcuts: ["CommandOrControl+O"]
defaultShortcuts: ["CommandOrControl+O"],
scope: "window"
},
{
actionName: "CreateNoteInto",
defaultShortcuts: ["CommandOrControl+P"]
defaultShortcuts: ["CommandOrControl+P"],
scope: "window"
},
{
actionName: "CreateNoteIntoDayNote",
defaultShortcuts: ["global:CommandOrControl+Alt+P"],
description: "Create and open subnote of a current day note"
description: "Create and open subnote of a current day note",
scope: "window"
},
{
actionName: "DeleteNotes",
@ -119,15 +128,18 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "EditBranchPrefix",
defaultShortcuts: ["F2"],
description: "Show Edit branch prefix dialog"
description: "Show Edit branch prefix dialog",
scope: "window"
},
{
actionName: "CloneNotesTo",
defaultShortcuts: ["CommandOrControl+Shift+C"]
defaultShortcuts: ["CommandOrControl+Shift+C"],
scope: "window"
},
{
actionName: "MoveNotesTo",
defaultShortcuts: ["CommandOrControl+Shift+X"]
defaultShortcuts: ["CommandOrControl+Shift+X"],
scope: "window"
},
{
@ -179,22 +191,26 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "OpenNewTab",
defaultShortcuts: isElectron ? ["CommandOrControl+T"] : [],
description: "Opens new tab"
description: "Opens new tab",
scope: "window"
},
{
actionName: "CloseActiveTab",
defaultShortcuts: isElectron ? ["CommandOrControl+W"] : [],
description: "Closes active tab"
description: "Closes active tab",
scope: "window"
},
{
actionName: "ActivateNextTab",
defaultShortcuts: isElectron ? ["CommandOrControl+Tab"] : [],
description: "Activates tab on the right"
description: "Activates tab on the right",
scope: "window"
},
{
actionName: "ActivatePreviousTab",
defaultShortcuts: isElectron ? ["CommandOrControl+Shift+Tab"] : [],
description: "Activates tab on the left"
description: "Activates tab on the left",
scope: "window"
},
@ -204,52 +220,62 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "ShowAttributes",
defaultShortcuts: ["Alt+A"],
description: "Shows Attributes dialog"
description: "Shows Attributes dialog",
scope: "window"
},
{
actionName: "ShowNoteInfo",
defaultShortcuts: [],
description: "Shows Note Info dialog"
description: "Shows Note Info dialog",
scope: "window"
},
{
actionName: "ShowNoteSource",
defaultShortcuts: [],
description: "Shows Note Source dialog"
description: "Shows Note Source dialog",
scope: "window"
},
{
actionName: "ShowLinkMap",
defaultShortcuts: [],
description: "Shows Link Map dialog"
description: "Shows Link Map dialog",
scope: "window"
},
{
actionName: "ShowOptions",
defaultShortcuts: [],
description: "Shows Options dialog"
description: "Shows Options dialog",
scope: "window"
},
{
actionName: "ShowNoteRevisions",
defaultShortcuts: [],
description: "Shows Note Revisions dialog"
description: "Shows Note Revisions dialog",
scope: "window"
},
{
actionName: "ShowRecentChanges",
defaultShortcuts: [],
description: "Shows Recent Changes dialog"
description: "Shows Recent Changes dialog",
scope: "window"
},
{
actionName: "ShowSQLConsole",
defaultShortcuts: ["Alt+O"],
description: "Shows SQL Console dialog"
description: "Shows SQL Console dialog",
scope: "window"
},
{
actionName: "ShowBackendLog",
defaultShortcuts: [],
description: "Shows Backend Log dialog"
description: "Shows Backend Log dialog",
scope: "window"
},
{
actionName: "ShowHelp",
defaultShortcuts: ["F1"],
description: "Shows built-in Help / cheatsheet"
description: "Shows built-in Help / cheatsheet",
scope: "window"
},
@ -260,21 +286,25 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "AddLinkToText",
defaultShortcuts: ["CommandOrControl+L"],
description: "Open dialog to add link to the text"
description: "Open dialog to add link to the text",
scope: "text-detail"
},
{
actionName: "InsertDateTimeToText",
defaultShortcuts: ["Alt+T"]
defaultShortcuts: ["Alt+T"],
scope: "text-detail"
},
{
actionName: "PasteMarkdownIntoText",
defaultShortcuts: [],
description: "Pastes Markdown from clipboard into text note"
description: "Pastes Markdown from clipboard into text note",
scope: "text-detail"
},
{
actionName: "CutIntoNote",
defaultShortcuts: [],
description: "Cuts the selection from the current note and creates subnote with the selected text"
description: "Cuts the selection from the current note and creates subnote with the selected text",
scope: "text-detail"
},
{
@ -283,49 +313,60 @@ const DEFAULT_KEYBOARD_ACTIONS = [
{
actionName: "PrintActiveNote",
defaultShortcuts: []
defaultShortcuts: [],
scope: "note-detail"
},
{
actionName: "RunActiveNote",
defaultShortcuts: ["CommandOrControl+Enter"],
description: "Run active JavaScript (frontend/backend) code note"
description: "Run active JavaScript (frontend/backend) code note",
scope: "code-detail"
},
{
actionName: "ToggleNoteHoisting",
defaultShortcuts: ["Alt+H"],
description: "Toggles note hoisting of active note"
description: "Toggles note hoisting of active note",
scope: "window"
},
{
actionName: "ReloadFrontendApp",
defaultShortcuts: ["F5", "CommandOrControl+R"]
defaultShortcuts: ["F5", "CommandOrControl+R"],
scope: "window"
},
{
actionName: "OpenDevTools",
defaultShortcuts: ["CommandOrControl+Shift+I"]
defaultShortcuts: ["CommandOrControl+Shift+I"],
scope: "window"
},
{
actionName: "FindInText",
defaultShortcuts: ["CommandOrControl+F"]
defaultShortcuts: ["CommandOrControl+F"],
scope: "window"
},
{
actionName: "ToggleFullscreen",
defaultShortcuts: ["F11"]
defaultShortcuts: ["F11"],
scope: "window"
},
{
actionName: "ToggleZenMode",
defaultShortcuts: ["Alt+M"]
defaultShortcuts: ["Alt+M"],
scope: "window"
},
{
actionName: "ZoomOut",
defaultShortcuts: ["CommandOrControl+-"]
defaultShortcuts: ["CommandOrControl+-"],
scope: "window"
},
{
actionName: "ZoomIn",
defaultShortcuts: ["CommandOrControl+="]
defaultShortcuts: ["CommandOrControl+="],
scope: "window"
},
{
actionName: "CopyWithoutFormatting",
defaultShortcuts: ["CommandOrControl+Alt+C"]
defaultShortcuts: ["CommandOrControl+Alt+C"],
scope: "text-detail"
}
];
@ -341,9 +382,7 @@ async function getKeyboardActions() {
const actions = JSON.parse(JSON.stringify(DEFAULT_KEYBOARD_ACTIONS));
for (const action of actions) {
if (action.defaultShortcuts) {
action.effectiveShortcuts = action.defaultShortcuts.slice();
}
action.effectiveShortcuts = action.effectiveShortcuts ? action.defaultShortcuts.slice() : [];
}
for (const option of await optionService.getOptions()) {

View file

@ -18,12 +18,12 @@
<ul>
<li><kbd>UP</kbd>, <kbd>DOWN</kbd> - go up/down in the list of notes</li>
<li><kbd>LEFT</kbd>, <kbd>RIGHT</kbd> - collapse/expand node</li>
<li><kbd data-kb-action="BackInNoteHistory"></kbd>, <kbd data-kb-action="BackInNoteHistory"></kbd> - go back / forwards in the history</li>
<li><kbd data-kb-action="JumpToNote"></kbd> - show <a class="external" href="https://github.com/zadam/trilium/wiki/Note-navigation#jump-to-note">"Jump to" dialog</a></li>
<li><kbd data-kb-action="ScrollToActiveNote"></kbd> - scroll to active note</li>
<li><kbd data-kb-action="ActivateParentNote"></kbd> - jumps to parent note</li>
<li><kbd data-kb-action="CollapseTree"></kbd> - collapse whole note tree</li>
<li><kbd data-kb-action="CollapseSubtree"></kbd> - collapse sub-tree</li>
<li><kbd data-kb-action="backInNoteHistory"></kbd>, <kbd data-kb-action="BackInNoteHistory"></kbd> - go back / forwards in the history</li>
<li><kbd data-kb-action="jumpToNote"></kbd> - show <a class="external" href="https://github.com/zadam/trilium/wiki/Note-navigation#jump-to-note">"Jump to" dialog</a></li>
<li><kbd data-kb-action="scrollToActiveNote"></kbd> - scroll to active note</li>
<li><kbd data-kb-action="activateParentNote"></kbd> - jumps to parent note</li>
<li><kbd data-kb-action="collapseTree"></kbd> - collapse whole note tree</li>
<li><kbd data-kb-action="collapseSubtree"></kbd> - collapse sub-tree</li>
</ul>
</p>
</div>
@ -40,10 +40,10 @@
Only in desktop (electron build):
<ul>
<li><kbd data-kb-action="OpenNewTab"></kbd> opens empty tab</li>
<li><kbd data-kb-action="CloseActiveTab"></kbd> closes active tab</li>
<li><kbd data-kb-action="ActivateNextTab"></kbd> activates next tab</li>
<li><kbd data-kb-action="ActivatePreviousTab"></kbd> activates previous tab</li>
<li><kbd data-kb-action="openNewTab"></kbd> opens empty tab</li>
<li><kbd data-kb-action="closeActiveTab"></kbd> closes active tab</li>
<li><kbd data-kb-action="activateNextTab"></kbd> activates next tab</li>
<li><kbd data-kb-action="activatePreviousTab"></kbd> activates previous tab</li>
</ul>
</p>
</div>
@ -55,9 +55,9 @@
<p class="card-text">
<ul>
<li><kbd data-kb-action="CreateNoteAfter"></kbd> - creates new note after the active note</li>
<li><kbd data-kb-action="CreateNoteInto"></kbd> - creates new sub-note into active note</li>
<li><kbd data-kb-action="EditBranchPrefix"></kbd> - edit <a class="external" href="https://github.com/zadam/trilium/wiki/Tree concepts#prefix">prefix</a> of active note clone</li>
<li><kbd data-kb-action="createNoteAfter"></kbd> - creates new note after the active note</li>
<li><kbd data-kb-action="createNoteInto"></kbd> - creates new sub-note into active note</li>
<li><kbd data-kb-action="editBranchPrefix"></kbd> - edit <a class="external" href="https://github.com/zadam/trilium/wiki/Tree concepts#prefix">prefix</a> of active note clone</li>
</ul>
</p>
</div>
@ -69,15 +69,15 @@
<p class="card-text">
<ul>
<li><kbd data-kb-action="MoveNoteUp"></kbd>, <kbd data-kb-action="MoveNoteDown"></kbd> - move note up/down in the note list</li>
<li><kbd data-kb-action="MoveNoteUpInHierarchy"></kbd>, <kbd data-kb-action="MoveNoteDownInHierarchy"></kbd> - move note up in the hierarchy</li>
<li><kbd data-kb-action="AddNoteAboveToSelection"></kbd>, <kbd data-kb-action="AddNoteBelowToSelection"></kbd> - multi-select note above/below</li>
<li><kbd data-kb-action="SelectAllNotesInParent"></kbd> - select all notes in the current level</li>
<li><kbd data-kb-action="moveNoteUp"></kbd>, <kbd data-kb-action="MoveNoteDown"></kbd> - move note up/down in the note list</li>
<li><kbd data-kb-action="moveNoteUpInHierarchy"></kbd>, <kbd data-kb-action="MoveNoteDownInHierarchy"></kbd> - move note up in the hierarchy</li>
<li><kbd data-kb-action="addNoteAboveToSelection"></kbd>, <kbd data-kb-action="AddNoteBelowToSelection"></kbd> - multi-select note above/below</li>
<li><kbd data-kb-action="selectAllNotesInParent"></kbd> - select all notes in the current level</li>
<li><kbd>Shift+click</kbd> - select note</li>
<li><kbd data-kb-action="CopyNotesToClipboard"></kbd> - copies active note (or current selection) into clipboard (used for <a class="external" href="https://github.com/zadam/trilium/wiki/Cloning notes">cloning</a>)</li>
<li><kbd data-kb-action="CutNotesToClipboard"></kbd> - cuts current (or current selection) note into clipboard (used for moving notes)</li>
<li><kbd data-kb-action="PasteNotesFromClipboard"></kbd> - pastes note(s) as sub-note into active note (which is either move or clone depending on whether it was copied or cut into clipboard)</li>
<li><kbd data-kb-action="DeleteNotes"></kbd> - delete note / sub-tree</li>
<li><kbd data-kb-action="copyNotesToClipboard"></kbd> - copies active note (or current selection) into clipboard (used for <a class="external" href="https://github.com/zadam/trilium/wiki/Cloning notes">cloning</a>)</li>
<li><kbd data-kb-action="cutNotesToClipboard"></kbd> - cuts current (or current selection) note into clipboard (used for moving notes)</li>
<li><kbd data-kb-action="pasteNotesFromClipboard"></kbd> - pastes note(s) as sub-note into active note (which is either move or clone depending on whether it was copied or cut into clipboard)</li>
<li><kbd data-kb-action="deleteNotes"></kbd> - delete note / sub-tree</li>
</ul>
</p>
</div>
@ -89,12 +89,12 @@
<p class="card-text">
<ul>
<li><kbd data-kb-action="EditNoteTitle"></kbd> in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor.
<kbd data-kb-action="ScrollToActiveNote"></kbd> switches back from editor to tree pane.</li>
<li><kbd data-kb-action="editNoteTitle"></kbd> in tree pane switches from tree pane into note title. Enter from note title switches focus to text editor.
<kbd data-kb-action="scrollToActiveNote"></kbd> switches back from editor to tree pane.</li>
<li><kbd>Ctrl+K</kbd> - create / edit external link</li>
<li><kbd data-kb-action="AddLinkToText"></kbd> - create internal link</li>
<li><kbd data-kb-action="InsertDateTimeToText"></kbd> - inserts current date and time at caret position</li>
<li><kbd data-kb-action="ScrollToActiveNote"></kbd> - jump away to the tree pane and scroll to active note</li>
<li><kbd data-kb-action="addLinkToText"></kbd> - create internal link</li>
<li><kbd data-kb-action="insertDateTimeToText"></kbd> - inserts current date and time at caret position</li>
<li><kbd data-kb-action="scrollToActiveNote"></kbd> - jump away to the tree pane and scroll to active note</li>
</ul>
</p>
</div>
@ -121,9 +121,9 @@
<p class="card-text">
<ul>
<li><kbd data-kb-action="ReloadFrontendApp"></kbd> - reloads Trilium frontend</li>
<li><kbd data-kb-action="OpenDevTools"></kbd> - show developer tools</li>
<li><kbd data-kb-action="ShowSQLConsole"></kbd> - show SQL console</li>
<li><kbd data-kb-action="reloadFrontendApp"></kbd> - reloads Trilium frontend</li>
<li><kbd data-kb-action="openDevTools"></kbd> - show developer tools</li>
<li><kbd data-kb-action="showSQLConsole"></kbd> - show SQL console</li>
</ul>
</p>
</div>
@ -135,10 +135,10 @@
<p class="card-text">
<ul>
<li><kbd data-kb-action="ToggleZenMode"></kbd> - Zen mode - display only note editor, everything else is hidden</li>
<li><kbd data-kb-action="SearchNotes"></kbd> - toggle search form in tree pane</li>
<li><kbd data-kb-action="FindInText"></kbd> - in page search</li>
<li><kbd data-kb-action="ShowAttributes"></kbd> - show note attributes dialog</li>
<li><kbd data-kb-action="toggleZenMode"></kbd> - Zen mode - display only note editor, everything else is hidden</li>
<li><kbd data-kb-action="searchNotes"></kbd> - toggle search form in tree pane</li>
<li><kbd data-kb-action="findInText"></kbd> - in page search</li>
<li><kbd data-kb-action="showAttributes"></kbd> - show note attributes dialog</li>
</ul>
</p>
</div>