|
|
|
|
@ -42,30 +42,49 @@ function getResults(query) {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
results.sort((a, b) => a.title < b.title ? -1 : 1);
|
|
|
|
|
|
|
|
|
|
return results;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function search(noteIds, tokens, path, results) {
|
|
|
|
|
if (!noteIds) {
|
|
|
|
|
if (!noteIds || noteIds.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const noteId of noteIds) {
|
|
|
|
|
if (noteId === 'root') {
|
|
|
|
|
if (tokens.length === 0) {
|
|
|
|
|
const reversedPath = path.slice();
|
|
|
|
|
reversedPath.reverse();
|
|
|
|
|
if (tokens.length === 0) {
|
|
|
|
|
let curNoteId = noteIds[0];
|
|
|
|
|
|
|
|
|
|
const noteTitle = getNoteTitle(reversedPath);
|
|
|
|
|
while (curNoteId !== 'root') {
|
|
|
|
|
path.push(curNoteId);
|
|
|
|
|
|
|
|
|
|
console.log(noteTitle);
|
|
|
|
|
const parents = childToParent[curNoteId];
|
|
|
|
|
|
|
|
|
|
results.push({
|
|
|
|
|
title: noteTitle,
|
|
|
|
|
path: reversedPath.join('/')
|
|
|
|
|
});
|
|
|
|
|
if (!parents || parents.length === 0) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
curNoteId = parents[0];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path.reverse();
|
|
|
|
|
|
|
|
|
|
const noteTitle = getNoteTitle(path);
|
|
|
|
|
|
|
|
|
|
results.push({
|
|
|
|
|
title: noteTitle,
|
|
|
|
|
path: path.join('/')
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (const noteId of noteIds) {
|
|
|
|
|
if (results.length >= 200) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (noteId === 'root') {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|