diff --git a/static/css/notes2.css b/static/css/notes2.css index 017124a..04c9f68 100644 --- a/static/css/notes2.css +++ b/static/css/notes2.css @@ -9,7 +9,7 @@ --line-color: #ccc; --tree-expander: 0px; - --functions-width: 150px; + --functions-width: 180px; } html { diff --git a/static/images/icon_new_document.svg b/static/images/icon_new_document.svg new file mode 100644 index 0000000..a105e05 --- /dev/null +++ b/static/images/icon_new_document.svg @@ -0,0 +1,49 @@ + + + + + + + + file-document-plus-outline + + + diff --git a/static/js/app.mjs b/static/js/app.mjs index 4127b91..876d11d 100644 --- a/static/js/app.mjs +++ b/static/js/app.mjs @@ -82,19 +82,18 @@ export class App { keyHandler(event) {//{{{ let handled = true - if (event.key == 'F2') { - this.nodeUI.renameNode() - return - } - - // All keybindings is Alt+Shift, since the popular browsers at the time (2023) allows to override thees. + // Most keybindings is Alt+Shift, since the popular browsers at the time (2023) allows to override thees. // Ctrl+S is the exception to using Alt+Shift, since it is overridable and in such widespread use for saving. // Thus, the exception is acceptable to consequent use of alt+shift. - if (!(event.shiftKey && event.altKey) && !(event.key.toUpperCase() === 'S' && event.ctrlKey)) - return + const SHIFT_ALT = event.shiftKey && !event.ctrlKey && event.altKey + const SHIFT_CTRL_ALT = event.shiftKey && event.ctrlKey && event.altKey switch (event.key.toUpperCase()) { + case 'F2': + this.nodeUI.renameNode() + break case 'T': + if (!SHIFT_ALT) break if (document.activeElement.id === 'tree-nodes') this.nodeUI.takeFocus() else @@ -102,18 +101,25 @@ export class App { break case 'F': + if (!SHIFT_ALT) break _mbus.dispatch('op-search') break case 'M': + if (!SHIFT_ALT) break globalThis._mbus.dispatch('MARKDOWN_TOGGLE') break case 'N': - this.createNode() + if (SHIFT_ALT) + this.createNode() + else if (SHIFT_CTRL_ALT) { + this.createNode(this.currentNode?.ParentUUID) + } break case 'S': + if (!SHIFT_ALT) break this.nodeUI.saveNode() break @@ -142,17 +148,20 @@ export class App { async saveNode() {//{{{ }//}}} - async createNode() {//{{{ - let name = prompt("Name") + async createNode(createUnderUUID) {//{{{ + const parentUUID = createUnderUUID ? createUnderUUID : this.currentNode.UUID + const p = createUnderUUID ? 'Name for sibling document' : 'Name for sub-document' + + let name = prompt(p) if (!name) return - const nn = Node.create(name, this.currentNode.UUID) + const nn = Node.create(name, parentUUID) await nn.save() // Treenode is forcefully rerendered and children refetched to both show the new node // and to get it resorted. - const parentTreenode = this.sidebar.getTreeNode(this.currentNode.UUID) + const parentTreenode = this.sidebar.getTreeNode(parentUUID) await parentTreenode.render(true, true) _mbus.dispatch('GO_TO_NODE', { nodeUUID: nn.UUID }) }//}}} diff --git a/static/js/page_node.mjs b/static/js/page_node.mjs index 28388f8..b86b172 100644 --- a/static/js/page_node.mjs +++ b/static/js/page_node.mjs @@ -9,10 +9,11 @@ export class N2PageNodeUI extends CustomHTMLElement {