mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
when resolving note path attempt to find one going through hoisted note
This commit is contained in:
parent
f8c310eb8f
commit
73514a63d8
793
package-lock.json
generated
793
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -54,7 +54,7 @@
|
||||
"jsdom": "^16.4.0",
|
||||
"mime-types": "2.1.29",
|
||||
"multer": "1.4.2",
|
||||
"node-abi": "2.19.3",
|
||||
"node-abi": "2.20.0",
|
||||
"open": "7.4.2",
|
||||
"portscanner": "2.2.0",
|
||||
"rand-token": "1.0.1",
|
||||
@ -78,8 +78,8 @@
|
||||
},
|
||||
"devDependencies": {
|
||||
"cross-env": "7.0.3",
|
||||
"electron": "9.4.3",
|
||||
"electron-builder": "22.9.1",
|
||||
"electron": "9.4.4",
|
||||
"electron-builder": "22.10.5",
|
||||
"electron-packager": "15.2.0",
|
||||
"electron-rebuild": "2.3.5",
|
||||
"esm": "3.2.25",
|
||||
@ -87,7 +87,7 @@
|
||||
"jsdoc": "3.6.6",
|
||||
"lorem-ipsum": "2.0.3",
|
||||
"rcedit": "3.0.0",
|
||||
"webpack": "5.24.2",
|
||||
"webpack": "5.24.3",
|
||||
"webpack-cli": "4.5.0"
|
||||
},
|
||||
"optionalDependencies": {
|
||||
|
@ -542,7 +542,7 @@ class NoteShort {
|
||||
});
|
||||
}
|
||||
|
||||
hasAncestor(ancestorNote, visitedNoteIds) {
|
||||
hasAncestor(ancestorNote, visitedNoteIds = null) {
|
||||
if (this.noteId === ancestorNote.noteId) {
|
||||
return true;
|
||||
}
|
||||
|
@ -79,7 +79,7 @@ class TabContext extends Component {
|
||||
return inputNotePath;
|
||||
}
|
||||
|
||||
const resolvedNotePath = await treeService.resolveNotePath(inputNotePath);
|
||||
const resolvedNotePath = await treeService.resolveNotePath(inputNotePath, this.hoistedNoteId);
|
||||
|
||||
if (!resolvedNotePath) {
|
||||
logError(`Cannot resolve note path ${inputNotePath}`);
|
||||
|
@ -205,7 +205,7 @@ export default class TabManager extends Component {
|
||||
let hoistedNoteId = 'root';
|
||||
|
||||
if (tabContext) {
|
||||
const resolvedNotePath = await treeService.resolveNotePath(notePath);
|
||||
const resolvedNotePath = await treeService.resolveNotePath(notePath, tabContext.hoistedNoteId);
|
||||
|
||||
if (resolvedNotePath.includes(tabContext.hoistedNoteId)) {
|
||||
hoistedNoteId = tabContext.hoistedNoteId;
|
||||
|
@ -8,8 +8,8 @@ import appContext from "./app_context.js";
|
||||
/**
|
||||
* @return {string|null}
|
||||
*/
|
||||
async function resolveNotePath(notePath) {
|
||||
const runPath = await resolveNotePathToSegments(notePath);
|
||||
async function resolveNotePath(notePath, hoistedNoteId = 'root') {
|
||||
const runPath = await resolveNotePathToSegments(notePath, hoistedNoteId);
|
||||
|
||||
return runPath ? runPath.join("/") : null;
|
||||
}
|
||||
@ -21,7 +21,7 @@ async function resolveNotePath(notePath) {
|
||||
*
|
||||
* @return {string[]}
|
||||
*/
|
||||
async function resolveNotePathToSegments(notePath, logErrors = true) {
|
||||
async function resolveNotePathToSegments(notePath, hoistedNoteId = 'root', logErrors = true) {
|
||||
utils.assertArguments(notePath);
|
||||
|
||||
// we might get notePath with the tabId suffix, remove it if present
|
||||
@ -75,7 +75,11 @@ async function resolveNotePathToSegments(notePath, logErrors = true) {
|
||||
console.log(utils.now(), `Did not find parent ${parentNoteId} (${parent ? parent.title : 'n/a'}) for child ${childNoteId} (${child.title}), available parents: ${parents.map(p => `${p.noteId} (${p.title})`)}`);
|
||||
}
|
||||
|
||||
const someNotePath = getSomeNotePath(parents[0]);
|
||||
const hoistedNote = await treeCache.getNote(hoistedNoteId);
|
||||
|
||||
const chosenParent = parents.find(parent => parent.hasAncestor(hoistedNote))
|
||||
|| parents[0]; // if no parent is in hoisted subtree then it just doesn't matter and pick any
|
||||
const someNotePath = getSomeNotePath(chosenParent);
|
||||
|
||||
if (someNotePath) { // in case it's root the path may be empty
|
||||
const pathToRoot = someNotePath.split("/").reverse();
|
||||
|
@ -807,7 +807,7 @@ export default class NoteTreeWidget extends TabAwareWidget {
|
||||
/** @let {FancytreeNode} */
|
||||
let parentNode = this.getNodesByNoteId('root')[0];
|
||||
|
||||
const resolvedNotePathSegments = (await treeService.resolveNotePathToSegments(notePath, logErrors))
|
||||
const resolvedNotePathSegments = (await treeService.resolveNotePathToSegments(notePath, this.hoistedNoteId, logErrors))
|
||||
.slice(1);
|
||||
|
||||
if (!resolvedNotePathSegments) {
|
||||
|
@ -22,6 +22,10 @@ export default class TabAwareWidget extends BasicWidget {
|
||||
return this.tabContext && this.tabContext.notePath;
|
||||
}
|
||||
|
||||
get hoistedNoteId() {
|
||||
return this.tabContext && this.tabContext.hoistedNoteId;
|
||||
}
|
||||
|
||||
isEnabled() {
|
||||
return !!this.note;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user