Skip to content

Build your personal knowledge base with Trilium Notes

chore(print/list): get note titles to render

Elian Doran7f81b839550d
diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx
index 1d5a968106..860886a0f0 100644
--- a/apps/client/src/widgets/collections/NoteList.tsx
+++ b/apps/client/src/widgets/collections/NoteList.tsx
@@ -2,7 +2,7 @@ import { allViewTypes, ViewModeMedia, ViewModeProps, ViewTypeOptions } from "./i
import { useNoteContext, useNoteLabel, useNoteLabelBoolean, useTriliumEvent } from "../react/hooks";
import FNote from "../../entities/fnote";
import "./NoteList.css";
-import { ListView, GridView } from "./legacy/ListOrGridView";
+import { ListView, GridView, ListPrintView } from "./legacy/ListOrGridView";
import { useEffect, useRef, useState } from "preact/hooks";
import GeoView from "./geomap";
import ViewModeStorage from "./view_mode_storage";
@@ -103,7 +103,11 @@ export function CustomNoteList({ note, viewType, isEnabled: shouldEnable, notePa
function getComponentByViewType(viewType: ViewTypeOptions, props: ViewModeProps<any>) {
switch (viewType) {
case "list":
- return <ListView {...props} />;
+ if (props.media !== "print") {
+ return <ListView {...props} />;
+ } else {
+ return <ListPrintView {...props} />;
+ }
case "grid":
return <GridView {...props} />;
case "geoMap":
diff --git a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx
index ef37b6685e..db5a885936 100644
--- a/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx
+++ b/apps/client/src/widgets/collections/legacy/ListOrGridView.tsx
@@ -11,6 +11,7 @@ import tree from "../../../services/tree";
import link from "../../../services/link";
import { t } from "../../../services/i18n";
import attribute_renderer from "../../../services/attribute_renderer";
+import froca from "../../../services/froca";
export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
const [ isExpanded ] = useNoteLabelBoolean(note, "expanded");
@@ -34,6 +35,25 @@ export function ListView({ note, noteIds: unfilteredNoteIds, highlightedTokens }
);
}
+export function ListPrintView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
+ const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
+ const [ notes, setNotes ] = useState<FNote[]>();
+
+ useEffect(() => {
+ froca.getNotes(noteIds).then(setNotes);
+ }, [noteIds]);
+
+ return (
+ <div class="note-list list-print-view">
+ <div class="note-list-container use-tn-links">
+ {notes?.map(childNote => (
+ <h1>{childNote.title}</h1>
+ ))}
+ </div>
+ </div>
+ );
+}
+
export function GridView({ note, noteIds: unfilteredNoteIds, highlightedTokens }: ViewModeProps<{}>) {
const noteIds = useFilteredNoteIds(note, unfilteredNoteIds);
const { pageNotes, ...pagination } = usePagination(note, noteIds);