provide also explicit unhoist keyboard shortcut, #1305

This commit is contained in:
zadam 2020-10-13 23:41:55 +02:00
parent a1ec6fe0aa
commit 893b6053d2
6 changed files with 22 additions and 3 deletions

View File

@ -91,6 +91,10 @@ export default class Entrypoints extends Component {
} }
} }
async unhoistCommand() {
hoistedNoteService.unhoist();
}
copyWithoutFormattingCommand() { copyWithoutFormattingCommand() {
utils.copySelectionToClipboard(); utils.copySelectionToClipboard();
} }

View File

@ -8,6 +8,10 @@ function getHoistedNoteId() {
} }
async function setHoistedNoteId(noteId) { async function setHoistedNoteId(noteId) {
if (getHoistedNoteId() === noteId) {
return;
}
await options.save('hoistedNoteId', noteId); await options.save('hoistedNoteId', noteId);
await treeCache.loadInitialTree(); await treeCache.loadInitialTree();

View File

@ -111,5 +111,6 @@ export default {
setElementActionHandler, setElementActionHandler,
updateDisplayedShortcuts, updateDisplayedShortcuts,
setupActionsForElement, setupActionsForElement,
getActionsForScope getActionsForScope,
getAction
}; };

View File

@ -69,7 +69,7 @@ class TreeContextMenu {
{ title: 'Search in subtree <kbd data-command="searchInSubtree"></kbd>', command: "searchInSubtree", uiIcon: "search", { title: 'Search in subtree <kbd data-command="searchInSubtree"></kbd>', command: "searchInSubtree", uiIcon: "search",
enabled: notSearch && noSelectedNotes }, enabled: notSearch && noSelectedNotes },
isHoisted ? null : { title: 'Hoist note <kbd data-command="toggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, isHoisted ? null : { title: 'Hoist note <kbd data-command="toggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "empty", enabled: noSelectedNotes && notSearch },
!isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-command="ToggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "arrow-up" }, !isHoisted || !isNotRoot ? null : { title: 'Unhoist note <kbd data-command="ToggleNoteHoisting"></kbd>', command: "toggleNoteHoisting", uiIcon: "arrow-from-bottom" },
{ title: 'Edit branch prefix <kbd data-command="editBranchPrefix"></kbd>', command: "editBranchPrefix", uiIcon: "empty", { title: 'Edit branch prefix <kbd data-command="editBranchPrefix"></kbd>', command: "editBranchPrefix", uiIcon: "empty",
enabled: isNotRoot && parentNotSearch && noSelectedNotes}, enabled: isNotRoot && parentNotSearch && noSelectedNotes},
{ title: "Advanced", uiIcon: "empty", enabled: true, items: [ { title: "Advanced", uiIcon: "empty", enabled: true, items: [

View File

@ -460,7 +460,11 @@ export default class NoteTreeWidget extends TabAwareWidget {
&& node.data.noteId === hoistedNoteService.getHoistedNoteId() && node.data.noteId === hoistedNoteService.getHoistedNoteId()
&& $span.find('.unhoist-button').length === 0) { && $span.find('.unhoist-button').length === 0) {
const unhoistButton = $('<span class="unhoist-button-wrapper" title="Unhoist current note to show the whole note tree">[<a class="unhoist-button">unhoist</a>]</span>'); const action = await keyboardActionsService.getAction('unhoist');
let shortcuts = action.effectiveShortcuts.join(',');
shortcuts = shortcuts ? `(${shortcuts})` : '';
const unhoistButton = $(`<span class="unhoist-button-wrapper" title="Unhoist current note to show the whole note tree ${shortcuts}">[<a class="unhoist-button">unhoist</a>]</span>`);
// prepending since appending could push out (when note title is too long) // prepending since appending could push out (when note title is too long)
// the button too much to the right so that it's not visible // the button too much to the right so that it's not visible

View File

@ -352,6 +352,12 @@ const DEFAULT_KEYBOARD_ACTIONS = [
description: "Toggles note hoisting of active note", description: "Toggles note hoisting of active note",
scope: "window" scope: "window"
}, },
{
actionName: "unhoist",
defaultShortcuts: ["Alt+U"],
description: "Unhoist from anywhere",
scope: "window"
},
{ {
actionName: "reloadFrontendApp", actionName: "reloadFrontendApp",
defaultShortcuts: ["F5", "CommandOrControl+R"], defaultShortcuts: ["F5", "CommandOrControl+R"],