global keyboard shortcuts for quick creating sub-notes under day note

This commit is contained in:
azivner
2018-02-12 23:53:00 -05:00
parent 7bbfef7af3
commit 0e9473119e
5 changed files with 109 additions and 38 deletions

View File

@@ -640,16 +640,15 @@ const noteTree = (function() {
return document.location.hash.substr(1); // strip initial #
}
function loadTree() {
return server.get('tree').then(resp => {
startNotePath = resp.start_note_path;
async function loadTree() {
const resp = await server.get('tree');
startNotePath = resp.start_note_path;
if (document.location.hash) {
startNotePath = getNotePathFromAddress();
}
if (document.location.hash) {
startNotePath = getNotePathFromAddress();
}
return prepareNoteTree(resp.notes);
});
return prepareNoteTree(resp.notes);
}
$(() => loadTree().then(noteTree => initFancyTree(noteTree)));
@@ -775,7 +774,7 @@ const noteTree = (function() {
};
if (target === 'after') {
node.appendSibling(newNode).setActive(true);
await node.appendSibling(newNode).setActive(true);
}
else if (target === 'into') {
if (!node.getChildren() && node.isFolder()) {
@@ -785,7 +784,7 @@ const noteTree = (function() {
node.addChildren(newNode);
}
node.getLastChild().setActive(true);
await node.getLastChild().setActive(true);
node.folder = true;
node.renderTitle();
@@ -803,6 +802,10 @@ const noteTree = (function() {
await reload();
}
function noteExists(noteId) {
return !!childToParents[noteId];
}
$(document).bind('keydown', 'ctrl+o', e => {
const node = getCurrentNode();
const parentNoteId = node.data.parentNoteId;
@@ -876,6 +879,7 @@ const noteTree = (function() {
removeParentChildRelation,
setParentChildRelation,
getSelectedNodes,
sortAlphabetically
sortAlphabetically,
noteExists
};
})();