Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
updating also shortcuts in element titles
zadam1f37d00e426c
diff --git a/package-lock.json b/package-lock.jsonindex 4825557ec1..c1be109613 100644--- a/package-lock.json+++ b/package-lock.json@@ -725,6 +725,12 @@"temp-file": "^3.3.4"},"dependencies": {+ "ejs": {+ "version": "2.7.4",+ "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz",+ "integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==",+ "dev": true+ },"hosted-git-info": {"version": "3.0.2","resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-3.0.2.tgz",@@ -2432,6 +2438,14 @@"sanitize-filename": "^1.6.2","semver": "^6.3.0","temp-file": "^3.3.4"+ },+ "dependencies": {+ "ejs": {+ "version": "2.7.4",+ "resolved": "https://registry.npmjs.org/ejs/-/ejs-2.7.4.tgz",+ "integrity": "sha512-7vmuyh5+kuUyJKePhQfRQBhXV5Ce+RnaeeQArKu1EAMpL3WbgMt5WG6uQZpEVvYSSsxMXRKOewtDk9RaTKXRlA==",+ "dev": true+ }}},"builder-util": {diff --git a/src/public/javascripts/services/context_menu.js b/src/public/javascripts/services/context_menu.jsindex 4622b980ef..713490a55d 100644--- a/src/public/javascripts/services/context_menu.js+++ b/src/public/javascripts/services/context_menu.js@@ -70,7 +70,7 @@ async function initContextMenu(event, contextMenu) {addItems($contextMenuContainer, await contextMenu.getContextMenuItems());- keyboardActionService.updateKbdElements($contextMenuContainer);+ keyboardActionService.updateDisplayedShortcuts($contextMenuContainer);// code below tries to detect when dropdown would overflow from page// in such case we'll position it above click coordinates so it will fit into clientdiff --git a/src/public/javascripts/services/keyboard_actions.js b/src/public/javascripts/services/keyboard_actions.jsindex 1a77688cc4..886e7b0946 100644--- a/src/public/javascripts/services/keyboard_actions.js+++ b/src/public/javascripts/services/keyboard_actions.js@@ -78,7 +78,7 @@ async function getAction(actionName, silent = false) {return action;}-function updateKbdElements($container) {+function updateDisplayedShortcuts($container) {$container.find('kbd[data-kb-action]').each(async (i, el) => {const actionName = $(el).attr('data-kb-action');const action = await getAction(actionName, true);@@ -87,13 +87,26 @@ function updateKbdElements($container) {$(el).text(action.effectiveShortcuts.join(', '));}});++ $container.find('button[data-kb-action],a.icon-action[data-kb-action]').each(async (i, el) => {+ const actionName = $(el).attr('data-kb-action');+ const action = await getAction(actionName, true);++ if (action) {+ const title = $(el).attr('title');+ const shortcuts = action.effectiveShortcuts.join(', ');+ const newTitle = !title || !title.trim() ? shortcuts : `${title} (${shortcuts})`;++ $(el).attr('title', newTitle);+ }+ });}-$(() => updateKbdElements($(document)));+$(() => updateDisplayedShortcuts($(document)));export default {setActionHandler,triggerAction,getAction,- updateKbdElements+ updateDisplayedShortcuts};\ No newline at end of filediff --git a/src/public/javascripts/services/tree_context_menu.js b/src/public/javascripts/services/tree_context_menu.jsindex 344083608f..fbf5b7fdce 100644--- a/src/public/javascripts/services/tree_context_menu.js+++ b/src/public/javascripts/services/tree_context_menu.js@@ -72,9 +72,9 @@ class TreeContextMenu {enabled: isNotRoot && !isHoisted },{ title: 'Cut <kbd data-kb-action="CutNotesToClipboard"></kbd>', cmd: "cut", uiIcon: "cut",enabled: isNotRoot && !isHoisted && parentNotSearch },- { title: 'Move to ... <kbd data-kb-action="MoveNotesTo">Ctrl+Shift+X</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">Ctrl+V</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 },@@ -86,9 +86,9 @@ class TreeContextMenu {{ title: "Import into note", cmd: "importIntoNote", uiIcon: "empty",enabled: notSearch && noSelectedNotes },{ title: "----" },- { title: 'Collapse subtree <kbd data-kb-action="CollapseSubtree">Alt+-</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: "recycle", enabled: noSelectedNotes },- { title: 'Sort alphabetically <kbd data-kb-action="SortChildNotes">Alt+S</kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }+ { title: 'Sort alphabetically <kbd data-kb-action="SortChildNotes"></kbd>', cmd: "sortAlphabetically", uiIcon: "empty", enabled: noSelectedNotes && notSearch }].filter(row => row !== null);}diff --git a/src/views/desktop.ejs b/src/views/desktop.ejsindex 84071e1ffe..2ab23a61db 100644--- a/src/views/desktop.ejs+++ b/src/views/desktop.ejs@@ -18,24 +18,29 @@</div><div style="flex-grow: 100; display: flex;">- <button class="btn btn-sm" id="jump-to-note-dialog-button" title="CTRL+J">+ <button class="btn btn-sm" id="jump-to-note-dialog-button" data-kb-action="JumpToNote"><span class="bx bx-crosshair"></span>Jump to note</button>- <button class="btn btn-sm" id="recent-changes-button">+ <button class="btn btn-sm" id="recent-changes-button" data-kb-action="ShowRecentChanges"><span class="bx bx-history"></span>Recent changes</button>- <button class="btn btn-sm" id="enter-protected-session-button" title="Enter protected session to be able to find and view protected notes">+ <button class="btn btn-sm"+ id="enter-protected-session-button"+ title="Enter protected session to be able to find and view protected notes"><span class="bx bx-log-in"></span>Enter protected session</button>- <button class="btn btn-sm" id="leave-protected-session-button" title="Leave protected session so that protected notes are not accessible any more." style="display: none;">+ <button class="btn btn-sm"+ id="leave-protected-session-button"+ title="Leave protected session so that protected notes are not accessible any more."+ style="display: none;"><span class="bx bx-log-out"></span>Leave protected session@@ -117,11 +122,11 @@<div id="global-buttons"><a id="create-top-level-note-button" title="Create new top level note" class="icon-action bx bx-folder-plus"></a>- <a id="collapse-tree-button" title="Collapse note tree. Shortcut ALT+C" class="icon-action bx bx-layer-minus"></a>+ <a id="collapse-tree-button" title="Collapse note tree" data-kb-action="CollapseTree" class="icon-action bx bx-layer-minus"></a>- <a id="scroll-to-active-note-button" title="Scroll to active note. Shortcut CTRL+." class="icon-action bx bx-crosshair"></a>+ <a id="scroll-to-active-note-button" title="Scroll to active note" data-kb-action="ScrollToActiveNote" class="icon-action bx bx-crosshair"></a>- <a id="toggle-search-button" title="Search in notes. Shortcut CTRL+S" class="icon-action bx bx-search"></a>+ <a id="toggle-search-button" title="Search in notes" data-kb-action="SearchNotes" class="icon-action bx bx-search"></a></div><div id="search-box">diff --git a/src/views/dialogs/help.ejs b/src/views/dialogs/help.ejsindex 02ddd80a2e..ab4b4a50ae 100644--- a/src/views/dialogs/help.ejs+++ b/src/views/dialogs/help.ejs@@ -18,7 +18,7 @@<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">ALT+RIGHT</kbd> - go back / forwards in the history</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>@@ -42,8 +42,8 @@<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">CTRL+Tab</kbd> activates next tab</li>- <li><kbd data-kb-action="ActivatePreviousTab">CTRL+Shift+Tab</kbd> activates previous 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>@@ -72,12 +72,12 @@<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">CTRL+A</kbd> - select all notes in the current level</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">CTRL+C</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">CTRL+X</kbd> - cuts current (or current selection) note into clipboard (used for moving notes)</li>- <li><kbd data-kb-action="PasteNotesFromClipboard">CTRL+V</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">DEL</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,7 +89,8 @@<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>CTRL+.</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>@@ -122,7 +123,7 @@<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">ALT+O</kbd> - show SQL console</li>+ <li><kbd data-kb-action="ShowSQLConsole"></kbd> - show SQL console</li></ul></p></div>@@ -136,8 +137,8 @@<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">CTRL+F</kbd> - in page search</li>- <li><kbd data-kb-action="ShowAttributes">ALT+A</kbd> - show note attributes dialog</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>diff --git a/src/views/mobile.ejs b/src/views/mobile.ejsindex 9f82bbf7b2..3490915832 100644--- a/src/views/mobile.ejs+++ b/src/views/mobile.ejs@@ -17,9 +17,9 @@<div id="global-buttons"><a id="create-top-level-note-button" title="Create new top level note" class="icon-action bx bx-folder-plus"></a>- <a id="collapse-tree-button" title="Collapse note tree. Shortcut ALT+C" class="icon-action bx bx-layer-minus"></a>+ <a id="collapse-tree-button" title="Collapse note tree" class="icon-action bx bx-layer-minus"></a>- <a id="scroll-to-active-note-button" title="Scroll to active note. Shortcut CTRL+." class="icon-action bx bx-crosshair"></a>+ <a id="scroll-to-active-note-button" title="Scroll to active note" class="icon-action bx bx-crosshair"></a><div class="dropdown"><a id="global-actions-button" title="Global actions" class="icon-action bx bx-cog dropdown-toggle" data-toggle="dropdown"></a>