11import { useEffect , useLayoutEffect , useState } from "preact/hooks" ;
2- import { RawHtmlBlock } from "../../react/RawHtml" ;
32import froca from "../../../services/froca" ;
43import type FNote from "../../../entities/fnote" ;
54import content_renderer from "../../../services/content_renderer" ;
65import type { ViewModeProps } from "../interface" ;
7- import { useFilteredNoteIds } from "./utils" ;
6+ import { filterChildNotes , useFilteredNoteIds } from "./utils" ;
87
98interface NotesWithContent {
109 note : FNote ;
@@ -13,10 +12,11 @@ interface NotesWithContent {
1312
1413export function ListPrintView ( { note, noteIds : unfilteredNoteIds , onReady } : ViewModeProps < { } > ) {
1514 const noteIds = useFilteredNoteIds ( note , unfilteredNoteIds ) ;
16- const noteIdsSet = new Set < string > ( ) ;
1715 const [ notesWithContent , setNotesWithContent ] = useState < NotesWithContent [ ] > ( ) ;
1816
1917 useLayoutEffect ( ( ) => {
18+ const noteIdsSet = new Set < string > ( ) ;
19+
2020 froca . getNotes ( noteIds ) . then ( async ( notes ) => {
2121 const notesWithContent : NotesWithContent [ ] = [ ] ;
2222
@@ -34,9 +34,7 @@ export function ListPrintView({ note, noteIds: unfilteredNoteIds, onReady }: Vie
3434 notesWithContent . push ( { note, contentEl } ) ;
3535
3636 if ( note . hasChildren ( ) ) {
37- const imageLinks = note . getRelations ( "imageLink" ) ;
38- const childNotes = await note . getChildNotes ( ) ;
39- const filteredChildNotes = childNotes . filter ( ( childNote ) => ! imageLinks . find ( ( rel ) => rel . value === childNote . noteId ) ) ;
37+ const filteredChildNotes = await filterChildNotes ( note ) ;
4038 for ( const childNote of filteredChildNotes ) {
4139 await processNote ( childNote , depth + 1 ) ;
4240 }
@@ -82,7 +80,7 @@ function insertPageTitle(contentEl: HTMLElement, title: string) {
8280}
8381
8482function rewriteHeadings ( contentEl : HTMLElement , depth : number ) {
85- const headings = contentEl . querySelectorAll ( "h1, h2, h3, h4, h5, h6" )
83+ const headings = contentEl . querySelectorAll ( "h1, h2, h3, h4, h5, h6" ) ;
8684 for ( const headingEl of headings ) {
8785 const currentLevel = parseInt ( headingEl . tagName . substring ( 1 ) , 10 ) ;
8886 const newLevel = Math . min ( currentLevel + depth , 6 ) ;
0 commit comments