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() {
utils.copySelectionToClipboard();
}

View file

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

View file

@ -111,5 +111,6 @@ export default {
setElementActionHandler,
updateDisplayedShortcuts,
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",
enabled: notSearch && noSelectedNotes },
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",
enabled: isNotRoot && parentNotSearch && noSelectedNotes},
{ title: "Advanced", uiIcon: "empty", enabled: true, items: [

View file

@ -460,7 +460,11 @@ export default class NoteTreeWidget extends TabAwareWidget {
&& node.data.noteId === hoistedNoteService.getHoistedNoteId()
&& $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)
// 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",
scope: "window"
},
{
actionName: "unhoist",
defaultShortcuts: ["Alt+U"],
description: "Unhoist from anywhere",
scope: "window"
},
{
actionName: "reloadFrontendApp",
defaultShortcuts: ["F5", "CommandOrControl+R"],