mirror of
https://github.com/zadam/trilium.git
synced 2024-12-27 09:43:18 +08:00
51 lines
No EOL
1.1 KiB
JavaScript
51 lines
No EOL
1.1 KiB
JavaScript
function getParentKey(node) {
|
|
return (node.getParent() === null || node.getParent().key === "root_1") ? "root" : node.getParent().key;
|
|
}
|
|
|
|
function getParentEncryption(node) {
|
|
return node.getParent() === null ? 0 : node.getParent().data.encryption;
|
|
}
|
|
|
|
function getNodeByKey(noteId) {
|
|
return globalTree.fancytree('getNodeByKey', noteId);
|
|
}
|
|
|
|
function getNoteTitle(noteId) {
|
|
const note = getNodeByKey(noteId);
|
|
if (!note) {
|
|
return;
|
|
}
|
|
|
|
let noteTitle = note.title;
|
|
|
|
if (noteTitle.endsWith(" (clone)")) {
|
|
noteTitle = noteTitle.substr(0, noteTitle.length - 8);
|
|
}
|
|
|
|
return noteTitle;
|
|
}
|
|
|
|
function getFullName(noteId) {
|
|
let note = getNodeByKey(noteId);
|
|
|
|
if (note === null) {
|
|
return "[unknown]";
|
|
}
|
|
|
|
if (note.data.is_clone || (note.data.encryption > 0 && !isEncryptionAvailable())) {
|
|
return null;
|
|
}
|
|
|
|
const path = [];
|
|
|
|
while (note) {
|
|
path.push(note.title);
|
|
|
|
note = note.getParent();
|
|
}
|
|
|
|
// remove "root" element
|
|
path.pop();
|
|
|
|
return path.reverse().join(" > ");
|
|
} |