feat(print/list): process notes recursively

This commit is contained in:
Elian Doran 2025-11-20 20:31:45 +02:00
parent f4b6e9c25a
commit 4958b89636
No known key found for this signature in database

View File

@ -48,12 +48,27 @@ export function ListPrintView({ note, noteIds: unfilteredNoteIds, highlightedTok
useLayoutEffect(() => { useLayoutEffect(() => {
froca.getNotes(noteIds).then(async (notes) => { froca.getNotes(noteIds).then(async (notes) => {
const notesWithContent: NotesWithContent[] = []; const notesWithContent: NotesWithContent[] = [];
for (const note of notes) {
async function processNote(note: FNote) {
const content = await content_renderer.getRenderedContent(note, { const content = await content_renderer.getRenderedContent(note, {
trim: false, trim: false,
noChildrenList: true noChildrenList: true
}); });
notesWithContent.push({ note, content: content.$renderedContent[0].innerHTML }); notesWithContent.push({ note, content: content.$renderedContent[0].innerHTML });
if (note.hasChildren()) {
const imageLinks = note.getRelations("imageLink");
const childNotes = await note.getChildNotes();
const filteredChildNotes = childNotes.filter((childNote) => !imageLinks.find((rel) => rel.value === childNote.noteId));
for (const childNote of filteredChildNotes) {
await processNote(childNote);
}
}
}
for (const note of notes) {
await processNote(note);
} }
setNotesWithContent(notesWithContent); setNotesWithContent(notesWithContent);
}); });