mirror of
https://github.com/zadam/trilium.git
synced 2025-01-15 11:39:37 +08:00
hidden subtree is not archived anymore
This commit is contained in:
parent
b202b43bf5
commit
d34a0a9fc0
10 changed files with 64 additions and 42 deletions
13
db/migrations/0208__remove_archived_from_hidden.js
Normal file
13
db/migrations/0208__remove_archived_from_hidden.js
Normal file
|
@ -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');
|
||||
}
|
||||
});
|
||||
};
|
|
@ -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(", ");
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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}) => {
|
||||
|
|
|
@ -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";
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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 middle
|
||||
notePosition: 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;
|
||||
|
|
|
@ -10,6 +10,8 @@ function isHoistedInHiddenSubtree() {
|
|||
|
||||
if (hoistedNoteId === 'root') {
|
||||
return false;
|
||||
} else if (hoistedNoteId === 'hidden') {
|
||||
return true;
|
||||
}
|
||||
|
||||
const hoistedNote = becca.getNote(hoistedNoteId);
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue