mirror of
https://github.com/zadam/trilium.git
synced 2024-11-17 21:21:40 +08:00
40 lines
No EOL
864 B
JavaScript
40 lines
No EOL
864 B
JavaScript
"use strict";
|
|
|
|
const treeUtils = (function() {
|
|
const $tree = $("#tree");
|
|
|
|
function getParentProtectedStatus(node) {
|
|
return isTopLevelNode(node) ? 0 : node.getParent().data.isProtected;
|
|
}
|
|
|
|
function getNodeByKey(key) {
|
|
return $tree.fancytree('getNodeByKey', key);
|
|
}
|
|
|
|
function getNoteIdFromNotePath(notePath) {
|
|
const path = notePath.split("/");
|
|
|
|
return path[path.length - 1];
|
|
}
|
|
|
|
function getNotePath(node) {
|
|
const path = [];
|
|
|
|
while (node && !isRootNode(node)) {
|
|
if (node.data.noteId) {
|
|
path.push(node.data.noteId);
|
|
}
|
|
|
|
node = node.getParent();
|
|
}
|
|
|
|
return path.reverse().join("/");
|
|
}
|
|
|
|
return {
|
|
getParentProtectedStatus,
|
|
getNodeByKey,
|
|
getNotePath,
|
|
getNoteIdFromNotePath,
|
|
};
|
|
})(); |