From 98b579524ca4b275e33d7c2c768fa29ce1d8ecd9 Mon Sep 17 00:00:00 2001 From: zadam Date: Tue, 31 May 2022 22:45:57 +0200 Subject: [PATCH] create note from template WIP --- package-lock.json | 193 ++++-------------- package.json | 6 +- src/public/app/desktop.js | 16 +- src/public/app/services/context_menu.js | 2 +- src/public/app/services/link_context_menu.js | 6 +- src/public/app/services/tree_context_menu.js | 100 +++++---- .../attribute_widgets/attribute_editor.js | 8 +- src/public/app/widgets/history_navigation.js | 4 +- .../mobile_widgets/mobile_detail_menu.js | 4 +- src/public/app/widgets/tab_row.js | 6 +- .../app/widgets/type_widgets/relation_map.js | 8 +- src/routes/api/search.js | 12 +- src/routes/routes.js | 1 + src/services/builtin_attributes.js | 1 + 14 files changed, 141 insertions(+), 226 deletions(-) diff --git a/package-lock.json b/package-lock.json index 30a0dbed2..81b126892 100644 --- a/package-lock.json +++ b/package-lock.json @@ -44,8 +44,8 @@ "joplin-turndown-plugin-gfm": "1.0.12", "jsdom": "19.0.0", "mime-types": "2.1.35", - "multer": "1.4.4", - "node-abi": "3.21.0", + "multer": "1.4.5-lts.1", + "node-abi": "3.22.0", "normalize-strings": "1.1.1", "open": "8.4.0", "portscanner": "2.2.0", @@ -65,7 +65,7 @@ "tmp": "0.2.1", "turndown": "7.1.1", "unescape": "1.0.1", - "ws": "8.6.0", + "ws": "8.7.0", "yauzl": "2.10.0" }, "bin": { @@ -2161,38 +2161,16 @@ } }, "node_modules/busboy": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", - "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "dependencies": { - "dicer": "0.2.5", - "readable-stream": "1.1.x" + "streamsearch": "^1.1.0" }, "engines": { - "node": ">=0.8.0" + "node": ">=10.16.0" } }, - "node_modules/busboy/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "node_modules/busboy/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/busboy/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "node_modules/bytes": { "version": "3.1.2", "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.2.tgz", @@ -3267,39 +3245,6 @@ "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==", "optional": true }, - "node_modules/dicer": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", - "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", - "dependencies": { - "readable-stream": "1.1.x", - "streamsearch": "0.1.2" - }, - "engines": { - "node": ">=0.8.0" - } - }, - "node_modules/dicer/node_modules/isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "node_modules/dicer/node_modules/readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "dependencies": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "node_modules/dicer/node_modules/string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - }, "node_modules/dir-compare": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-2.4.0.tgz", @@ -7359,21 +7304,20 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "node_modules/multer": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4.tgz", - "integrity": "sha512-2wY2+xD4udX612aMqMcB8Ws2Voq6NIUPEtD1be6m411T4uDH/VtL9i//xvcyFlTVfRdaBsk7hV5tgrGQqhuBiw==", + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", "dependencies": { "append-field": "^1.0.0", - "busboy": "^0.2.11", + "busboy": "^1.0.0", "concat-stream": "^1.5.2", "mkdirp": "^0.5.4", "object-assign": "^4.1.1", - "on-finished": "^2.3.0", "type-is": "^1.6.4", "xtend": "^4.0.0" }, "engines": { - "node": ">= 0.10.0" + "node": ">= 6.0.0" } }, "node_modules/nanoid": { @@ -7407,9 +7351,9 @@ "dev": true }, "node_modules/node-abi": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.21.0.tgz", - "integrity": "sha512-0ChvtQmmNYzXju0fjG0Vfg72q2D8FxUhluvV9uqivtXsKblSekJE2juxfg+9HoSgqPMqCmVEC/GHHtGzi4xYTg==", + "version": "3.22.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.22.0.tgz", + "integrity": "sha512-u4uAs/4Zzmp/jjsD9cyFYDXeISfUWaAVWshPmDZOFOv4Xl4SbzTXm53I04C2uRueYJ+0t5PEtLH/owbn2Npf/w==", "dependencies": { "semver": "^7.3.5" }, @@ -9463,11 +9407,11 @@ "integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==" }, "node_modules/streamsearch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==", "engines": { - "node": ">=0.8.0" + "node": ">=10.0.0" } }, "node_modules/string_decoder": { @@ -10594,9 +10538,9 @@ } }, "node_modules/ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz", + "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==", "engines": { "node": ">=10.0.0" }, @@ -12550,35 +12494,11 @@ } }, "busboy": { - "version": "0.2.14", - "resolved": "https://registry.npmjs.org/busboy/-/busboy-0.2.14.tgz", - "integrity": "sha1-bCpiLvz0fFe7vh4qnDetNseSVFM=", + "version": "1.6.0", + "resolved": "https://registry.npmjs.org/busboy/-/busboy-1.6.0.tgz", + "integrity": "sha512-8SFQbg/0hQ9xy3UNTB0YEnsNBbWfhf7RtnzpL7TkBiTBRfrQ9Fxcnz7VJsleJpyp6rVLvXiuORqjlHi5q+PYuA==", "requires": { - "dicer": "0.2.5", - "readable-stream": "1.1.x" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } + "streamsearch": "^1.1.0" } }, "bytes": { @@ -13383,38 +13303,6 @@ "integrity": "sha512-ZIzRpLJrOj7jjP2miAtgqIfmzbxa4ZOr5jJc601zklsfEx9oTzmmj2nVpIPRpNlRTIh8lc1kyViIY7BWSGNmKw==", "optional": true }, - "dicer": { - "version": "0.2.5", - "resolved": "https://registry.npmjs.org/dicer/-/dicer-0.2.5.tgz", - "integrity": "sha1-WZbAhrszIYyBLAkL3cCc0S+stw8=", - "requires": { - "readable-stream": "1.1.x", - "streamsearch": "0.1.2" - }, - "dependencies": { - "isarray": { - "version": "0.0.1", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-0.0.1.tgz", - "integrity": "sha1-ihis/Kmo9Bd+Cav8YDiTmwXR7t8=" - }, - "readable-stream": { - "version": "1.1.14", - "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", - "integrity": "sha1-fPTFTvZI44EwhMY23SB54WbAgdk=", - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.1", - "isarray": "0.0.1", - "string_decoder": "~0.10.x" - } - }, - "string_decoder": { - "version": "0.10.31", - "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", - "integrity": "sha1-YuIDvEF2bGwoyfyEMB2rHFMQ+pQ=" - } - } - }, "dir-compare": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/dir-compare/-/dir-compare-2.4.0.tgz", @@ -16530,16 +16418,15 @@ "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" }, "multer": { - "version": "1.4.4", - "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.4.tgz", - "integrity": "sha512-2wY2+xD4udX612aMqMcB8Ws2Voq6NIUPEtD1be6m411T4uDH/VtL9i//xvcyFlTVfRdaBsk7hV5tgrGQqhuBiw==", + "version": "1.4.5-lts.1", + "resolved": "https://registry.npmjs.org/multer/-/multer-1.4.5-lts.1.tgz", + "integrity": "sha512-ywPWvcDMeH+z9gQq5qYHCCy+ethsk4goepZ45GLD63fOu0YcNecQxi64nDs3qluZB+murG3/D4dJ7+dGctcCQQ==", "requires": { "append-field": "^1.0.0", - "busboy": "^0.2.11", + "busboy": "^1.0.0", "concat-stream": "^1.5.2", "mkdirp": "^0.5.4", "object-assign": "^4.1.1", - "on-finished": "^2.3.0", "type-is": "^1.6.4", "xtend": "^4.0.0" } @@ -16566,9 +16453,9 @@ "dev": true }, "node-abi": { - "version": "3.21.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.21.0.tgz", - "integrity": "sha512-0ChvtQmmNYzXju0fjG0Vfg72q2D8FxUhluvV9uqivtXsKblSekJE2juxfg+9HoSgqPMqCmVEC/GHHtGzi4xYTg==", + "version": "3.22.0", + "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-3.22.0.tgz", + "integrity": "sha512-u4uAs/4Zzmp/jjsD9cyFYDXeISfUWaAVWshPmDZOFOv4Xl4SbzTXm53I04C2uRueYJ+0t5PEtLH/owbn2Npf/w==", "requires": { "semver": "^7.3.5" } @@ -18169,9 +18056,9 @@ } }, "streamsearch": { - "version": "0.1.2", - "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-0.1.2.tgz", - "integrity": "sha1-gIudDlb8Jz2Am6VzOOkpkZoanxo=" + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/streamsearch/-/streamsearch-1.1.0.tgz", + "integrity": "sha512-Mcc5wHehp9aXz1ax6bZUyY5afg9u2rv5cqQI3mRrYkGC8rW2hM02jWuwjtL++LS5qinSyhj2QfLyNsuc+VsExg==" }, "string_decoder": { "version": "1.1.1", @@ -19028,9 +18915,9 @@ } }, "ws": { - "version": "8.6.0", - "resolved": "https://registry.npmjs.org/ws/-/ws-8.6.0.tgz", - "integrity": "sha512-AzmM3aH3gk0aX7/rZLYvjdvZooofDu3fFOzGqcSnQ1tOcTWwhM/o+q++E8mAyVVIyUdajrkzWUGftaVSDLn1bw==", + "version": "8.7.0", + "resolved": "https://registry.npmjs.org/ws/-/ws-8.7.0.tgz", + "integrity": "sha512-c2gsP0PRwcLFzUiA8Mkr37/MI7ilIlHQxaEAtd0uNMbVMoy8puJyafRlm0bV9MbGSabUPeLrRRaqIBcFcA2Pqg==", "requires": {} }, "xdg-basedir": { diff --git a/package.json b/package.json index a20a1043f..2900aa455 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,8 @@ "joplin-turndown-plugin-gfm": "1.0.12", "jsdom": "19.0.0", "mime-types": "2.1.35", - "multer": "1.4.4", - "node-abi": "3.21.0", + "multer": "1.4.5-lts.1", + "node-abi": "3.22.0", "normalize-strings": "1.1.1", "open": "8.4.0", "portscanner": "2.2.0", @@ -80,7 +80,7 @@ "tmp": "0.2.1", "turndown": "7.1.1", "unescape": "1.0.1", - "ws": "8.6.0", + "ws": "8.7.0", "yauzl": "2.10.0" }, "devDependencies": { diff --git a/src/public/app/desktop.js b/src/public/app/desktop.js index 6ab84b3b3..5c7eb8996 100644 --- a/src/public/app/desktop.js +++ b/src/public/app/desktop.js @@ -52,13 +52,13 @@ if (utils.isElectron()) { title: suggestion, command: "replaceMisspelling", spellingSuggestion: suggestion, - uiIcon: "empty" + uiIcon: "bx bx-empty" }); } items.push({ title: `Add "${params.misspelledWord}" to dictionary`, - uiIcon: "plus", + uiIcon: "bx bx-plus", handler: () => webContents.session.addWordToSpellCheckerDictionary(params.misspelledWord) }); @@ -69,7 +69,7 @@ if (utils.isElectron()) { items.push({ enabled: editFlags.canCut && hasText, title: `Cut ${platformModifier}+X`, - uiIcon: "cut", + uiIcon: "bx bx-cut", handler: () => webContents.cut() }); } @@ -78,7 +78,7 @@ if (utils.isElectron()) { items.push({ enabled: editFlags.canCopy && hasText, title: `Copy ${platformModifier}+C`, - uiIcon: "copy", + uiIcon: "bx bx-copy", handler: () => webContents.copy() }); } @@ -86,7 +86,7 @@ if (utils.isElectron()) { if (!["", "javascript:", "about:blank#blocked"].includes(params.linkURL) && params.mediaType === 'none') { items.push({ title: `Copy link`, - uiIcon: "copy", + uiIcon: "bx bx-copy", handler: () => { electron.clipboard.write({ bookmark: params.linkText, @@ -100,7 +100,7 @@ if (utils.isElectron()) { items.push({ enabled: editFlags.canPaste, title: `Paste ${platformModifier}+V`, - uiIcon: "paste", + uiIcon: "bx bx-paste", handler: () => webContents.paste() }); } @@ -109,7 +109,7 @@ if (utils.isElectron()) { items.push({ enabled: editFlags.canPaste, title: `Paste as plain text ${platformModifier}+Shift+V`, - uiIcon: "paste", + uiIcon: "bx bx-paste", handler: () => webContents.pasteAndMatchStyle() }); } @@ -122,7 +122,7 @@ if (utils.isElectron()) { items.push({ enabled: editFlags.canPaste, title: `Search for "${shortenedSelection}" with DuckDuckGo`, - uiIcon: "search-alt", + uiIcon: "bx bx-search-alt", handler: () => electron.shell.openExternal(`https://duckduckgo.com/?q=${encodeURIComponent(params.selectionText)}`) }); } diff --git a/src/public/app/services/context_menu.js b/src/public/app/services/context_menu.js index acbb3a3e4..806efd188 100644 --- a/src/public/app/services/context_menu.js +++ b/src/public/app/services/context_menu.js @@ -82,7 +82,7 @@ class ContextMenu { const $icon = $(""); if (item.uiIcon) { - $icon.addClass("bx bx-" + item.uiIcon); + $icon.addClass(item.uiIcon); } else { $icon.append(" "); } diff --git a/src/public/app/services/link_context_menu.js b/src/public/app/services/link_context_menu.js index 6c1e972cc..84239c22a 100644 --- a/src/public/app/services/link_context_menu.js +++ b/src/public/app/services/link_context_menu.js @@ -6,9 +6,9 @@ function openContextMenu(notePath, e) { x: e.pageX, y: e.pageY, items: [ - {title: "Open note in a new tab", command: "openNoteInNewTab", uiIcon: "empty"}, - {title: "Open note in a new split", command: "openNoteInNewSplit", uiIcon: "dock-right"}, - {title: "Open note in a new window", command: "openNoteInNewWindow", uiIcon: "window-open"} + {title: "Open note in a new tab", command: "openNoteInNewTab", uiIcon: "bx bx-empty"}, + {title: "Open note in a new split", command: "openNoteInNewSplit", uiIcon: "bx bx-dock-right"}, + {title: "Open note in a new window", command: "openNoteInNewWindow", uiIcon: "bx bx-window-open"} ], selectMenuItemHandler: ({command}) => { if (command === 'openNoteInNewTab') { diff --git a/src/public/app/services/tree_context_menu.js b/src/public/app/services/tree_context_menu.js index c5516762b..60003dd0a 100644 --- a/src/public/app/services/tree_context_menu.js +++ b/src/public/app/services/tree_context_menu.js @@ -4,6 +4,7 @@ import clipboard from './clipboard.js'; import noteCreateService from "./note_create.js"; import contextMenu from "./context_menu.js"; import appContext from "./app_context.js"; +import server from "./server.js"; class TreeContextMenu { /** @@ -24,19 +25,35 @@ class TreeContextMenu { }) } - getNoteTypeItems(command) { - return [ - { title: "Text", command: command, type: "text", uiIcon: "note" }, - { title: "Code", command: command, type: "code", uiIcon: "code" }, - { title: "Saved Search", command: command, type: "search", uiIcon: "file-find" }, - { title: "Relation Map", command: command, type: "relation-map", uiIcon: "map-alt" }, - { title: "Note Map", command: command, type: "note-map", uiIcon: "map-alt" }, - { title: "Render Note", command: command, type: "render", uiIcon: "extension" }, - { title: "Book", command: command, type: "book", uiIcon: "book" }, - { title: "Mermaid Diagram", command: command, type: "mermaid", uiIcon: "selection" }, - { title: "Canvas", command: command, type: "canvas", uiIcon: "pen" }, - { title: "Web View", command: command, type: "iframe", uiIcon: "globe-alt" }, + async getNoteTypeItems(command) { + const items = [ + { title: "Text", command: command, type: "text", uiIcon: "bx bx-note" }, + { title: "Code", command: command, type: "code", uiIcon: "bx bx-code" }, + { title: "Saved Search", command: command, type: "search", uiIcon: "bx bx-file-find" }, + { title: "Relation Map", command: command, type: "relation-map", uiIcon: "bx bx-map-alt" }, + { title: "Note Map", command: command, type: "note-map", uiIcon: "bx bx-map-alt" }, + { title: "Render Note", command: command, type: "render", uiIcon: "bx bx-extension" }, + { title: "Book", command: command, type: "book", uiIcon: "bx bx-book" }, + { title: "Mermaid Diagram", command: command, type: "mermaid", uiIcon: "bx bx-selection" }, + { title: "Canvas", command: command, type: "canvas", uiIcon: "bx bx-pen" }, + { title: "Web View", command: command, type: "iframe", uiIcon: "bx bx-globe-alt" }, ]; + + const templateNoteIds = await server.get("search-templates"); + const templateNotes = await froca.getNotes(templateNoteIds); + + if (items.length > 0) { + items.push({ title: "----" }); + + for (const templateNote of templateNotes) { + items.push({ + title: templateNote.title, + uiIcon: templateNote.getIcon() + }); + } + } + + return items; } async getMenuItems() { @@ -58,60 +75,59 @@ class TreeContextMenu { const insertNoteAfterEnabled = isNotRoot && !isHoisted && parentNotSearch; return [ - { title: 'Open in a new tab Ctrl+Click', command: "openInTab", uiIcon: "empty", enabled: noSelectedNotes }, - { title: 'Open in a new split', command: "openNoteInSplit", uiIcon: "dock-right", enabled: noSelectedNotes }, - { title: 'Insert note after ', command: "insertNoteAfter", uiIcon: "plus", - items: insertNoteAfterEnabled ? this.getNoteTypeItems("insertNoteAfter") : null, + { title: 'Open in a new tab Ctrl+Click', command: "openInTab", uiIcon: "bx bx-empty", enabled: noSelectedNotes }, + { title: 'Open in a new split', command: "openNoteInSplit", uiIcon: "bx bx-dock-right", enabled: noSelectedNotes }, + { title: 'Insert note after ', command: "insertNoteAfter", uiIcon: "bx bx-plus", + items: insertNoteAfterEnabled ? await this.getNoteTypeItems("insertNoteAfter") : null, enabled: insertNoteAfterEnabled && noSelectedNotes }, - { title: 'Insert child note ', command: "insertChildNote", uiIcon: "plus", - items: notSearch ? this.getNoteTypeItems("insertChildNote") : null, + { title: 'Insert child note ', command: "insertChildNote", uiIcon: "bx bx-plus", + items: notSearch ? await this.getNoteTypeItems("insertChildNote") : null, enabled: notSearch && noSelectedNotes }, - { title: 'Delete ', command: "deleteNotes", uiIcon: "trash", + { title: 'Delete ', command: "deleteNotes", uiIcon: "bx bx-trash", enabled: isNotRoot && !isHoisted && parentNotSearch }, { title: "----" }, - { title: 'Search in subtree ', command: "searchInSubtree", uiIcon: "search", + { title: 'Search in subtree ', command: "searchInSubtree", uiIcon: "bx bx-search", enabled: notSearch && noSelectedNotes }, - isHoisted ? null : { title: 'Hoist note ', command: "toggleNoteHoisting", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, - !isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', command: "toggleNoteHoisting", uiIcon: "door-open" }, - { title: 'Edit branch prefix ', command: "editBranchPrefix", uiIcon: "empty", + isHoisted ? null : { title: 'Hoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, + !isHoisted || !isNotRoot ? null : { title: 'Unhoist note ', command: "toggleNoteHoisting", uiIcon: "bx bx-door-open" }, + { title: 'Edit branch prefix ', command: "editBranchPrefix", uiIcon: "bx bx-empty", enabled: isNotRoot && parentNotSearch && noSelectedNotes}, - { title: "Advanced", uiIcon: "empty", enabled: true, items: [ - { title: 'Expand subtree ', command: "expandSubtree", uiIcon: "expand", enabled: noSelectedNotes }, - { title: 'Collapse subtree ', command: "collapseSubtree", uiIcon: "collapse", enabled: noSelectedNotes }, - { title: "Force note sync", command: "forceNoteSync", uiIcon: "refresh", enabled: noSelectedNotes }, - { title: 'Sort by ... ', command: "sortChildNotes", uiIcon: "empty", enabled: noSelectedNotes && notSearch }, - { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "history", enabled: noSelectedNotes } + { title: "Advanced", uiIcon: "bx bx-empty", enabled: true, items: [ + { title: 'Expand subtree ', command: "expandSubtree", uiIcon: "bx bx-expand", enabled: noSelectedNotes }, + { title: 'Collapse subtree ', command: "collapseSubtree", uiIcon: "bx bx-collapse", enabled: noSelectedNotes }, + { title: "Force note sync", command: "forceNoteSync", uiIcon: "bx bx-refresh", enabled: noSelectedNotes }, + { title: 'Sort by ... ', command: "sortChildNotes", uiIcon: "bx bx-empty", enabled: noSelectedNotes && notSearch }, + { title: 'Recent changes in subtree', command: "recentChangesInSubtree", uiIcon: "bx bx-history", enabled: noSelectedNotes } ] }, { title: "----" }, - { title: "Protect subtree", command: "protectSubtree", uiIcon: "check-shield", enabled: noSelectedNotes }, - { title: "Unprotect subtree", command: "unprotectSubtree", uiIcon: "shield", enabled: noSelectedNotes }, + { title: "Protect subtree", command: "protectSubtree", uiIcon: "bx bx-check-shield", enabled: noSelectedNotes }, + { title: "Unprotect subtree", command: "unprotectSubtree", uiIcon: "bx bx-shield", enabled: noSelectedNotes }, { title: "----" }, - { title: 'Copy / clone ', command: "copyNotesToClipboard", uiIcon: "copy", + { title: 'Copy / clone ', command: "copyNotesToClipboard", uiIcon: "bx bx-copy", enabled: isNotRoot && !isHoisted }, - { title: 'Clone to ... ', command: "cloneNotesTo", uiIcon: "empty", + { title: 'Clone to ... ', command: "cloneNotesTo", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted }, - { title: 'Cut ', command: "cutNotesToClipboard", uiIcon: "cut", + { title: 'Cut ', command: "cutNotesToClipboard", uiIcon: "bx bx-cut", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: 'Move to ... ', command: "moveNotesTo", uiIcon: "empty", + { title: 'Move to ... ', command: "moveNotesTo", uiIcon: "bx bx-empty", enabled: isNotRoot && !isHoisted && parentNotSearch }, - { title: 'Paste into ', command: "pasteNotesFromClipboard", uiIcon: "paste", + { title: 'Paste into ', command: "pasteNotesFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && notSearch && noSelectedNotes }, - { title: 'Paste after', command: "pasteNotesAfterFromClipboard", uiIcon: "paste", + { title: 'Paste after', command: "pasteNotesAfterFromClipboard", uiIcon: "bx bx-paste", enabled: !clipboard.isClipboardEmpty() && isNotRoot && !isHoisted && parentNotSearch && noSelectedNotes }, - { title: `Duplicate subtree `, command: "duplicateSubtree", uiIcon: "empty", + { title: `Duplicate subtree `, command: "duplicateSubtree", uiIcon: "bx bx-empty", enabled: parentNotSearch && isNotRoot && !isHoisted }, { title: "----" }, - { title: "Export", command: "exportNote", uiIcon: "empty", + { title: "Export", command: "exportNote", uiIcon: "bx bx-empty", enabled: notSearch && noSelectedNotes }, - { title: "Import into note", command: "importIntoNote", uiIcon: "empty", + { title: "Import into note", command: "importIntoNote", uiIcon: "bx bx-empty", enabled: notSearch && noSelectedNotes }, - { title: "Bulk assign attributes", command: "bulkAssignAttributes", uiIcon: "empty", + { title: "Bulk assign attributes", command: "bulkAssignAttributes", uiIcon: "bx bx-empty", enabled: true } ].filter(row => row !== null); } async selectMenuItemHandler({command, type}) { - const noteId = this.node.data.noteId; const notePath = treeService.getNotePath(this.node); if (command === 'openInTab') { diff --git a/src/public/app/widgets/attribute_widgets/attribute_editor.js b/src/public/app/widgets/attribute_widgets/attribute_editor.js index 614e74eb2..8ee1cc870 100644 --- a/src/public/app/widgets/attribute_widgets/attribute_editor.js +++ b/src/public/app/widgets/attribute_widgets/attribute_editor.js @@ -217,11 +217,11 @@ export default class AttributeEditorWidget extends NoteContextAwareWidget { y: e.pageY, orientation: 'left', items: [ - {title: `Add new label `, command: "addNewLabel", uiIcon: "hash"}, - {title: `Add new relation `, command: "addNewRelation", uiIcon: "transfer"}, + {title: `Add new label `, command: "addNewLabel", uiIcon: "bx bx-hash"}, + {title: `Add new relation `, command: "addNewRelation", uiIcon: "bx bx-transfer"}, {title: "----"}, - {title: "Add new label definition", command: "addNewLabelDefinition", uiIcon: "empty"}, - {title: "Add new relation definition", command: "addNewRelationDefinition", uiIcon: "empty"}, + {title: "Add new label definition", command: "addNewLabelDefinition", uiIcon: "bx bx-empty"}, + {title: "Add new relation definition", command: "addNewRelationDefinition", uiIcon: "bx bx-empty"}, ], selectMenuItemHandler: ({command}) => this.handleAddNewAttributeCommand(command) }); diff --git a/src/public/app/widgets/history_navigation.js b/src/public/app/widgets/history_navigation.js index f7e7513fb..4d18926df 100644 --- a/src/public/app/widgets/history_navigation.js +++ b/src/public/app/widgets/history_navigation.js @@ -65,8 +65,8 @@ export default class HistoryNavigationWidget extends BasicWidget { items.push({ title, idx, - uiIcon: idx == activeIndex ? "radio-circle-marked" : // compare with type coercion! - (idx < activeIndex ? "left-arrow-alt" : "right-arrow-alt") + uiIcon: idx == activeIndex ? "bx bx-radio-circle-marked" : // compare with type coercion! + (idx < activeIndex ? "bx bx-left-arrow-alt" : "bx bx-right-arrow-alt") }); } diff --git a/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js b/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js index 8d01c322a..8305a5bde 100644 --- a/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js +++ b/src/public/app/widgets/mobile_widgets/mobile_detail_menu.js @@ -18,9 +18,9 @@ class MobileDetailMenuWidget extends BasicWidget { x: e.pageX, y: e.pageY, items: [ - { title: "Insert child note", command: "insertChildNote", uiIcon: "plus", + { title: "Insert child note", command: "insertChildNote", uiIcon: "bx bx-plus", enabled: note.type !== 'search' }, - { title: "Delete this note", command: "delete", uiIcon: "trash", + { title: "Delete this note", command: "delete", uiIcon: "bx bx-trash", enabled: note.noteId !== 'root' } ], selectMenuItemHandler: async ({command}) => { diff --git a/src/public/app/widgets/tab_row.js b/src/public/app/widgets/tab_row.js index ece05003c..38921da5a 100644 --- a/src/public/app/widgets/tab_row.js +++ b/src/public/app/widgets/tab_row.js @@ -262,9 +262,9 @@ export default class TabRowWidget extends BasicWidget { x: e.pageX, y: e.pageY, items: [ - {title: "Move this tab to a new window", command: "moveTabToNewWindow", uiIcon: "window-open"}, - {title: "Close all tabs", command: "removeAllTabs", uiIcon: "x"}, - {title: "Close all tabs except for this", command: "removeAllTabsExceptForThis", uiIcon: "x"}, + {title: "Move this tab to a new window", command: "moveTabToNewWindow", uiIcon: "bx bx-window-open"}, + {title: "Close all tabs", command: "removeAllTabs", uiIcon: "bx bx-x"}, + {title: "Close all tabs except for this", command: "removeAllTabsExceptForThis", uiIcon: "bx bx-x"}, ], selectMenuItemHandler: ({command}) => { this.triggerCommand(command, {ntxId}); diff --git a/src/public/app/widgets/type_widgets/relation_map.js b/src/public/app/widgets/type_widgets/relation_map.js index f965a4c01..69b9781c8 100644 --- a/src/public/app/widgets/type_widgets/relation_map.js +++ b/src/public/app/widgets/type_widgets/relation_map.js @@ -138,9 +138,9 @@ export default class RelationMapTypeWidget extends TypeWidget { x: e.pageX, y: e.pageY, items: [ - {title: "Open in new tab", command: "openInNewTab", uiIcon: "empty"}, - {title: "Remove note", command: "remove", uiIcon: "trash"}, - {title: "Edit title", command: "editTitle", uiIcon: "pencil"}, + {title: "Open in new tab", command: "openInNewTab", uiIcon: "bx bx-empty"}, + {title: "Remove note", command: "remove", uiIcon: "bx bx-trash"}, + {title: "Edit title", command: "editTitle", uiIcon: "bx bx-pencil"}, ], selectMenuItemHandler: ({command}) => this.contextMenuHandler(command, e.target) }); @@ -446,7 +446,7 @@ export default class RelationMapTypeWidget extends TypeWidget { contextMenu.show({ x: event.pageX, y: event.pageY, - items: [ {title: "Remove relation", command: "remove", uiIcon: "trash"} ], + items: [ {title: "Remove relation", command: "remove", uiIcon: "bx bx-trash"} ], selectMenuItemHandler: async ({command}) => { if (command === 'remove') { const confirmDialog = await import('../../dialogs/confirm.js'); diff --git a/src/routes/api/search.js b/src/routes/api/search.js index ca64f24fe..5372540df 100644 --- a/src/routes/api/search.js +++ b/src/routes/api/search.js @@ -293,10 +293,20 @@ function getRelatedNotes(req) { }; } +function searchTemplates() { + const query = formatAttrForSearch({type: 'label', name: "template"}, false); + + return searchService.searchNotes(query, { + includeArchivedNotes: true, + ignoreHoistedNote: false + }).map(note => note.noteId); +} + module.exports = { searchFromNote, searchAndExecute, getRelatedNotes, quickSearch, - search + search, + searchTemplates }; diff --git a/src/routes/routes.js b/src/routes/routes.js index b51f1a521..29aaf93a1 100644 --- a/src/routes/routes.js +++ b/src/routes/routes.js @@ -355,6 +355,7 @@ function register(app) { apiRoute(POST, '/api/search-and-execute-note/:noteId', searchRoute.searchAndExecute); apiRoute(POST, '/api/search-related', searchRoute.getRelatedNotes); apiRoute(GET, '/api/search/:searchString', searchRoute.search); + apiRoute(GET, '/api/search-templates', searchRoute.searchTemplates); route(POST, '/api/login/sync', [], loginApiRoute.loginSync, apiResultHandler); // this is for entering protected mode so user has to be already logged-in (that's the reason we don't require username) diff --git a/src/services/builtin_attributes.js b/src/services/builtin_attributes.js index 31093ff06..fae7e1265 100644 --- a/src/services/builtin_attributes.js +++ b/src/services/builtin_attributes.js @@ -51,6 +51,7 @@ module.exports = [ { type: 'label', name: 'displayRelations' }, { type: 'label', name: 'hideRelations' }, { type: 'label', name: 'titleTemplate' }, + { type: 'label', name: 'template' }, // relation names { type: 'relation', name: 'internalLink' },