1- import { useEffect , useMemo , useRef , useState } from "preact/hooks" ;
1+ import { useEffect , useLayoutEffect , useMemo , useRef , useState } from "preact/hooks" ;
22import FNote from "../../../entities/fnote" ;
33import Icon from "../../react/Icon" ;
44import { ViewModeProps } from "../interface" ;
@@ -12,6 +12,7 @@ import link from "../../../services/link";
1212import { t } from "../../../services/i18n" ;
1313import attribute_renderer from "../../../services/attribute_renderer" ;
1414import froca from "../../../services/froca" ;
15+ import { RawHtmlBlock } from "../../react/RawHtml" ;
1516
1617export function ListView ( { note, noteIds : unfilteredNoteIds , highlightedTokens } : ViewModeProps < { } > ) {
1718 const [ isExpanded ] = useNoteLabelBoolean ( note , "expanded" ) ;
@@ -35,31 +36,43 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }
3536 ) ;
3637}
3738
39+ interface NotesWithContent {
40+ note : FNote ;
41+ content : string ;
42+ }
43+
3844export function ListPrintView ( { note, noteIds : unfilteredNoteIds , highlightedTokens, onReady } : ViewModeProps < { } > ) {
3945 const noteIds = useFilteredNoteIds ( note , unfilteredNoteIds ) ;
40- const [ notes , setNotes ] = useState < FNote [ ] > ( ) ;
41-
42- useEffect ( ( ) => {
43- froca . getNotes ( noteIds ) . then ( setNotes ) ;
46+ const [ notesWithContent , setNotesWithContent ] = useState < NotesWithContent [ ] > ( ) ;
47+
48+ useLayoutEffect ( ( ) => {
49+ froca . getNotes ( noteIds ) . then ( async ( notes ) => {
50+ const notesWithContent : NotesWithContent [ ] = [ ] ;
51+ for ( const note of notes ) {
52+ const content = await content_renderer . getRenderedContent ( note , {
53+ trim : false ,
54+ noChildrenList : true
55+ } ) ;
56+ notesWithContent . push ( { note, content : content . $renderedContent [ 0 ] . innerHTML } ) ;
57+ }
58+ setNotesWithContent ( notesWithContent ) ;
59+ } ) ;
4460 } , [ noteIds ] ) ;
4561
4662 useEffect ( ( ) => {
47- if ( notes && onReady ) {
63+ if ( notesWithContent && onReady ) {
4864 onReady ( ) ;
4965 }
50- } , [ notes , onReady ] ) ;
66+ } , [ notesWithContent , onReady ] ) ;
5167
5268 return (
5369 < div class = "note-list list-print-view" >
5470 < div class = "note-list-container use-tn-links" >
55- { notes ?. map ( childNote => (
56- < >
71+ { notesWithContent ?. map ( ( { note : childNote , content } ) => (
72+ < section id = { `note- ${ childNote . noteId } ` } class = "note" >
5773 < h1 > { childNote . title } </ h1 >
58- < NoteContent
59- note = { childNote }
60- highlightedTokens = { highlightedTokens }
61- />
62- </ >
74+ < RawHtmlBlock html = { content } />
75+ </ section >
6376 ) ) }
6477 </ div >
6578 </ div >
0 commit comments