mirror of
https://github.com/zadam/trilium.git
synced 2025-11-03 20:06:08 +01:00
moved services into the service directory
This commit is contained in:
40
src/public/javascripts/services/tree_utils.js
Normal file
40
src/public/javascripts/services/tree_utils.js
Normal file
@@ -0,0 +1,40 @@
|
||||
"use strict";
|
||||
|
||||
import utils from './utils.js';
|
||||
|
||||
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];
|
||||
}
|
||||
|
||||
function getNotePath(node) {
|
||||
const path = [];
|
||||
|
||||
while (node && !utils.isRootNode(node)) {
|
||||
if (node.data.noteId) {
|
||||
path.push(node.data.noteId);
|
||||
}
|
||||
|
||||
node = node.getParent();
|
||||
}
|
||||
|
||||
return path.reverse().join("/");
|
||||
}
|
||||
|
||||
export default {
|
||||
getParentProtectedStatus,
|
||||
getNodeByKey,
|
||||
getNotePath,
|
||||
getNoteIdFromNotePath,
|
||||
};
|
||||
Reference in New Issue
Block a user