trilium/src/public/javascripts/services/tree_utils.js

38 lines
756 B
JavaScript
Raw Normal View History

import utils from './utils.js';
2017-11-05 07:28:49 +08:00
const $tree = $("#tree");
function getParentProtectedStatus(node) {
return utils.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];
}
2017-11-19 21:47:22 +08:00
function getNotePath(node) {
const path = [];
2017-11-19 21:47:22 +08:00
while (node && !utils.isRootNode(node)) {
if (node.data.noteId) {
path.push(node.data.noteId);
2017-11-19 21:47:22 +08:00
}
node = node.getParent();
2017-11-19 21:47:22 +08:00
}
return path.reverse().join("/");
}
export default {
getParentProtectedStatus,
getNodeByKey,
getNotePath,
getNoteIdFromNotePath,
};