Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
hidden subtree is not archived anymore
zadamd34a0a9fc084
diff --git a/db/migrations/0208__remove_archived_from_hidden.js b/db/migrations/0208__remove_archived_from_hidden.jsnew file mode 100644index 0000000000..52089ee6b8--- /dev/null+++ b/db/migrations/0208__remove_archived_from_hidden.js@@ -0,0 +1,13 @@+module.exports = () => {+ const cls = require("../../src/services/cls");+ const beccaLoader = require("../../src/becca/becca_loader");+ const becca = require("../../src/becca/becca");++ cls.init(() => {+ beccaLoader.load();++ for (const label of becca.getNote('hidden').getLabels('archived')) {+ label.markAsDeleted('0208__remove_archived_from_hidden');+ }+ });+};diff --git a/src/etapi/validators.js b/src/etapi/validators.jsindex 73f8ac3111..797b617619 100644--- a/src/etapi/validators.js+++ b/src/etapi/validators.js@@ -1,4 +1,4 @@-const noteTypes = require("../services/note_types");+const noteTypeService = require("../services/note_types");function mandatory(obj) {if (obj === undefined ) {@@ -63,6 +63,8 @@ function isNoteType(obj) {return;}+ const noteTypes = noteTypeService.getNoteTypeNames();+if (!noteTypes.includes(obj)) {return `'${obj}' is not a valid note type, allowed types are: ` + noteTypes.join(", ");}diff --git a/src/public/app/entities/note_short.js b/src/public/app/entities/note_short.jsindex be7a549bb2..6635d3a3df 100644--- a/src/public/app/entities/note_short.js+++ b/src/public/app/entities/note_short.js@@ -354,6 +354,8 @@ class NoteShort {return a.isSearch ? 1 : -1;} else if (a.isArchived !== b.isArchived) {return a.isArchived ? 1 : -1;+ } else if (a.isHidden !== b.isHidden) {+ return a.isHidden ? 1 : -1;} else {return a.notePath.length - b.notePath.length;}diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.jsindex 6a277c2eee..1f48844d62 100644--- a/src/public/app/widgets/note_tree.js+++ b/src/public/app/widgets/note_tree.js@@ -605,11 +605,12 @@ export default class NoteTreeWidget extends NoteContextAwareWidget {this.$tree.on('contextmenu', '.fancytree-node', e => {const node = $.ui.fancytree.getNode(e);+ const note = froca.getNoteFromCache(node.data.noteId);- if (hoistedNoteService.getHoistedNoteId() === 'lbRoot') {- import("../menus/launcher_context_menu.js").then(({LauncherContextMenu: ShortcutContextMenu}) => {- const shortcutContextMenu = new LauncherContextMenu(this, node);- shortcutContextMenu.show(e);+ if (note.isLaunchBarConfig()) {+ import("../menus/launcher_context_menu.js").then(({default: LauncherContextMenu}) => {+ const launcherContextMenu = new LauncherContextMenu(this, node);+ launcherContextMenu.show(e);});} else {import("../menus/tree_context_menu.js").then(({default: TreeContextMenu}) => {diff --git a/src/services/app_info.js b/src/services/app_info.jsindex aefd41886b..c7c3e59493 100644--- a/src/services/app_info.js+++ b/src/services/app_info.js@@ -4,7 +4,7 @@ const build = require('./build');const packageJson = require('../../package');const {TRILIUM_DATA_DIR} = require('./data_dir');-const APP_DB_VERSION = 207;+const APP_DB_VERSION = 208;const SYNC_VERSION = 28;const CLIPPER_PROTOCOL_VERSION = "1.0";diff --git a/src/services/consistency_checks.js b/src/services/consistency_checks.jsindex 2b3b344e07..2d7230879b 100644--- a/src/services/consistency_checks.js+++ b/src/services/consistency_checks.js@@ -13,7 +13,7 @@ const attributeService = require('./attributes');const noteRevisionService = require('./note_revisions');const becca = require("../becca/becca");const utils = require("../services/utils");-const noteTypes = require("../services/note_types");+const noteTypes = require("../services/note_types").getNoteTypeNames();class ConsistencyChecks {constructor(autoFix) {diff --git a/src/services/hidden_subtree.js b/src/services/hidden_subtree.jsindex 4058df1bcf..cb00431849 100644--- a/src/services/hidden_subtree.js+++ b/src/services/hidden_subtree.js@@ -4,9 +4,9 @@ const log = require("./log");const LBTPL_ROOT = "lbTplRoot";const LBTPL_BASE = "lbTplBase";-const LBTPL_COMMAND = "lbTplCommand";+const LBTPL_COMMAND = "lbTplCommandLauncher";const LBTPL_NOTE_LAUNCHER = "lbTplNoteLauncher";-const LBTPL_SCRIPT = "lbTplScript";+const LBTPL_SCRIPT = "lbTplScriptLauncher";const LBTPL_BUILTIN_WIDGET = "lbTplBuiltinWidget";const LBTPL_SPACER = "lbTplSpacer";const LBTPL_CUSTOM_WIDGET = "lbTplCustomWidget";@@ -20,9 +20,6 @@ const HIDDEN_SUBTREE_DEFINITION = {// over tree when it's in the middlenotePosition: 999_999_999,attributes: [- // isInheritable: false means that this notePath is automatically not preffered but at the same time- // the flag is not inherited to the children- { type: 'label', name: 'archived' },{ type: 'label', name: 'excludeFromNoteMap', isInheritable: true }],children: [@@ -283,7 +280,7 @@ function checkHiddenSubtreeRecursively(parentNoteId, item) {if (!branch) {// not sure if there's some better way to recover- log.error(`Cannot find branch id='${item.id}', ignoring...`);+ log.error(`Cannot find launcher branch id='${item.id}', ignoring...`);} else {if (item.notePosition !== undefined && branch.notePosition !== item.notePosition) {branch.notePosition = item.notePosition;diff --git a/src/services/hoisted_note.js b/src/services/hoisted_note.jsindex 9b4d2f023a..0e38b895ca 100644--- a/src/services/hoisted_note.js+++ b/src/services/hoisted_note.js@@ -10,6 +10,8 @@ function isHoistedInHiddenSubtree() {if (hoistedNoteId === 'root') {return false;+ } else if (hoistedNoteId === 'hidden') {+ return true;}const hoistedNote = becca.getNote(hoistedNoteId);diff --git a/src/services/note_types.js b/src/services/note_types.jsindex 6e970f2d3a..65c715e6ef 100644--- a/src/services/note_types.js+++ b/src/services/note_types.js@@ -1,17 +1,33 @@-module.exports = [- 'text',- 'code',- 'render',- 'file',- 'image',- 'search',- 'relationMap',- 'book',- 'noteMap',- 'mermaid',- 'canvas',- 'webView',- 'launcher',- 'doc',- 'contentWidget'+const noteTypes = [+ { type: 'text', defaultMime: 'text/html' },+ { type: 'code', defaultMime: 'text/plain' },+ { type: 'render', defaultMime: '' },+ { type: 'file', defaultMime: 'application/octet-stream' },+ { type: 'image', defaultMime: '' },+ { type: 'search', defaultMime: '' },+ { type: 'relationMap', defaultMime: 'application/json' },+ { type: 'book', defaultMime: '' },+ { type: 'noteMap', defaultMime: '' },+ { type: 'mermaid', defaultMime: 'text/plain' },+ { type: 'canvas', defaultMime: 'application/json' },+ { type: 'webView', defaultMime: '' },+ { type: 'launcher', defaultMime: '' },+ { type: 'doc', defaultMime: '' },+ { type: 'contentWidget', defaultMime: '' }];++function getDefaultMimeForNoteType(typeName) {+ const typeRec = noteTypes.find(nt => nt.type === typeName);++ if (!typeRec) {+ throw new Error(`Cannot find note type '${typeName}'`);+ }++ return typeRec.defaultMime;+}++module.exports = {+ getNoteTypes: () => noteTypes,+ getNoteTypeNames: () => noteTypes.map(nt => nt.type),+ getDefaultMimeForNoteType+};diff --git a/src/services/notes.js b/src/services/notes.jsindex aa7bc5c26e..d74e96075e 100644--- a/src/services/notes.js+++ b/src/services/notes.js@@ -20,6 +20,7 @@ const Attribute = require('../becca/entities/attribute');const dayjs = require("dayjs");const htmlSanitizer = require("./html_sanitizer");const ValidationError = require("../errors/validation_error");+const noteTypesService = require("./note_types");function getNewNotePosition(parentNoteId) {const note = becca.notes[parentNoteId];@@ -47,19 +48,7 @@ function deriveMime(type, mime) {return mime;}- if (type === 'text') {- mime = 'text/html';- } else if (type === 'code' || type === 'mermaid') {- mime = 'text/plain';- } else if (['relationMap', 'search', 'canvas'].includes(type)) {- mime = 'application/json';- } else if (['render', 'book', 'webView'].includes(type)) {- mime = '';- } else {- mime = 'application/octet-stream';- }-- return mime;+ return noteTypesService.getDefaultMimeForNoteType(type);}function copyChildAttributes(parentNote, childNote) {