diff --git a/package-lock.json b/package-lock.json index 0c596e895..758d45014 100644 --- a/package-lock.json +++ b/package-lock.json @@ -22,6 +22,7 @@ "csurf": "1.11.0", "dayjs": "1.11.4", "dayjs-plugin-utc": "^0.1.2", + "debounce": "^1.2.1", "ejs": "3.1.8", "electron-debug": "3.2.0", "electron-dl": "3.3.1", @@ -3237,6 +3238,11 @@ "resolved": "https://registry.npmjs.org/dayjs-plugin-utc/-/dayjs-plugin-utc-0.1.2.tgz", "integrity": "sha512-ExERH5o3oo6jFOdkvMP3gytTCQ9Ksi5PtylclJWghr7k7m3o2U5QrwtdiJkOxLOH4ghr0EKhpqGefzGz1VvVJg==" }, + "node_modules/debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==" + }, "node_modules/debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", @@ -13266,6 +13272,11 @@ "resolved": "https://registry.npmjs.org/dayjs-plugin-utc/-/dayjs-plugin-utc-0.1.2.tgz", "integrity": "sha512-ExERH5o3oo6jFOdkvMP3gytTCQ9Ksi5PtylclJWghr7k7m3o2U5QrwtdiJkOxLOH4ghr0EKhpqGefzGz1VvVJg==" }, + "debounce": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/debounce/-/debounce-1.2.1.tgz", + "integrity": "sha512-XRRe6Glud4rd/ZGQfiV1ruXSfbvfJedlV9Y6zOlP+2K04vBYiJEte6stfFkCP03aMnY5tsipamumUjL14fofug==" + }, "debug": { "version": "4.3.4", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz", diff --git a/package.json b/package.json index df420fd30..253f9d8ec 100644 --- a/package.json +++ b/package.json @@ -38,6 +38,7 @@ "csurf": "1.11.0", "dayjs": "1.11.4", "dayjs-plugin-utc": "^0.1.2", + "debounce": "^1.2.1", "ejs": "3.1.8", "electron-debug": "3.2.0", "electron-dl": "3.3.1", diff --git a/src/etapi/etapi.openapi.yaml b/src/etapi/etapi.openapi.yaml index 1644e90bb..aeed8c778 100644 --- a/src/etapi/etapi.openapi.yaml +++ b/src/etapi/etapi.openapi.yaml @@ -706,7 +706,7 @@ components: type: string type: type: string - enum: [text, code, render, file, image, search, relation-map, book, note-map, mermaid] + enum: [text, code, render, file, image, search, relation-map, book, note-map, mermaid, web-view, shortcut] mime: type: string isProtected: diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.js index 7523ae6a7..bd07c0f85 100644 --- a/src/public/app/entities/note_short.js +++ b/src/public/app/entities/note_short.js @@ -19,7 +19,8 @@ const NOTE_TYPE_ICONS = { "note-map": "bx bx-map-alt", "mermaid": "bx bx-selection", "canvas": "bx bx-pen", - "web-view": "bx bx-globe-alt" + "web-view": "bx bx-globe-alt", + "shortcut": "bx bx-up-arrow-circle" }; /** diff --git a/src/public/app/menus/shortcut_context_menu.js b/src/public/app/menus/shortcut_context_menu.js index 0caae478f..7dc3c62de 100644 --- a/src/public/app/menus/shortcut_context_menu.js +++ b/src/public/app/menus/shortcut_context_menu.js @@ -25,7 +25,7 @@ export default class ShortcutContextMenu { async getMenuItems() { const note = await froca.getNote(this.node.data.noteId); - const branch = froca.getBranch(this.node.data.branchId); + const isLbRoot = note.noteId === 'lb_root'; const isVisibleRoot = note.noteId === 'lb_visibleshortcuts'; const isAvailableRoot = note.noteId === 'lb_availableshortcuts'; const isVisibleItem = this.node.getParent().data.noteId === 'lb_visibleshortcuts'; @@ -38,7 +38,7 @@ export default class ShortcutContextMenu { (isVisibleRoot || isAvailableRoot) ? { title: 'Add spacer', command: 'addSpacerShortcut', uiIcon: "bx bx-plus" } : null, (isVisibleRoot || isAvailableRoot) ? { title: "----" } : null, { title: 'Delete ', command: "deleteNotes", uiIcon: "bx bx-trash", - enabled: isItem }, + enabled: !isLbRoot}, // allow everything to be deleted as a form of a reset. Root can't be deleted because it's a hoisted note { title: "----" }, isAvailableItem ? { title: 'Move to visible shortcuts', command: "moveShortcutToVisible", uiIcon: "bx bx-show", enabled: true } : null, isVisibleItem ? { title: 'Move to available shortcuts', command: "moveShortcutToAvailable", uiIcon: "bx bx-hide", enabled: true } : null, @@ -47,46 +47,12 @@ export default class ShortcutContextMenu { ].filter(row => row !== null); } - async selectMenuItemHandler({command, type, templateNoteId}) { - const notePath = treeService.getNotePath(this.node); - - if (command === 'openInTab') { - appContext.tabManager.openTabWithNoteWithHoisting(notePath); - } - else if (command === "insertNoteAfter") { - const parentNotePath = treeService.getNotePath(this.node.getParent()); - const isProtected = await treeService.getParentProtectedStatus(this.node); - - noteCreateService.createNote(parentNotePath, { - target: 'after', - targetBranchId: this.node.data.branchId, - type: type, - isProtected: isProtected, - templateNoteId: templateNoteId - }); - } - else if (command === "insertChildNote") { - const parentNotePath = treeService.getNotePath(this.node); - - noteCreateService.createNote(parentNotePath, { - type: type, - isProtected: this.node.data.isProtected, - templateNoteId: templateNoteId - }); - } - else if (command === 'openNoteInSplit') { - const subContexts = appContext.tabManager.getActiveContext().getSubContexts(); - const {ntxId} = subContexts[subContexts.length - 1]; - - this.treeWidget.triggerCommand("openNewNoteSplit", {ntxId, notePath}); - } - else { - this.treeWidget.triggerCommand(command, { - node: this.node, - notePath: notePath, - selectedOrActiveBranchIds: this.treeWidget.getSelectedOrActiveBranchIds(this.node), - selectedOrActiveNoteIds: this.treeWidget.getSelectedOrActiveNoteIds(this.node) - }); - } + async selectMenuItemHandler({command}) { + this.treeWidget.triggerCommand(command, { + node: this.node, + notePath: treeService.getNotePath(this.node), + selectedOrActiveBranchIds: this.treeWidget.getSelectedOrActiveBranchIds(this.node), + selectedOrActiveNoteIds: this.treeWidget.getSelectedOrActiveNoteIds(this.node) + }); } } diff --git a/src/public/app/widgets/containers/shortcut_container.js b/src/public/app/widgets/containers/shortcut_container.js index 65e5b555c..3686121a3 100644 --- a/src/public/app/widgets/containers/shortcut_container.js +++ b/src/public/app/widgets/containers/shortcut_container.js @@ -22,7 +22,13 @@ export default class ShortcutContainer extends FlexContainer { async load() { this.children = []; - const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts'); + const visibleShortcutsRoot = await froca.getNote('lb_visibleshortcuts', true); + + if (!visibleShortcutsRoot) { + console.log("Visible shortcuts root note doesn't exist."); + + return; + } for (const shortcut of await visibleShortcutsRoot.getChildNotes()) { if (shortcut.getLabelValue("command")) { diff --git a/src/public/app/widgets/note_detail.js b/src/public/app/widgets/note_detail.js index 0bffc6e74..ded3dfdf3 100644 --- a/src/public/app/widgets/note_detail.js +++ b/src/public/app/widgets/note_detail.js @@ -25,6 +25,7 @@ import ReadOnlyCodeTypeWidget from "./type_widgets/read_only_code.js"; import NoneTypeWidget from "./type_widgets/none.js"; import NoteMapTypeWidget from "./type_widgets/note_map.js"; import WebViewTypeWidget from "./type_widgets/web_view.js"; +import DocTypeWidget from "./type_widgets/doc.js"; const TPL = `