From e374b31a1ca7b90fa7610a69c0d83a1c939c2bc6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sat, 18 Oct 2025 21:35:19 +0300 Subject: [PATCH] feat(client/print): get collections to render --- apps/client/src/print.css | 5 +++ apps/client/src/print.tsx | 41 ++++++++----------- .../src/widgets/collections/NoteList.tsx | 17 +------- .../collections/presentation/print.tsx | 5 --- 4 files changed, 23 insertions(+), 45 deletions(-) create mode 100644 apps/client/src/print.css delete mode 100644 apps/client/src/widgets/collections/presentation/print.tsx diff --git a/apps/client/src/print.css b/apps/client/src/print.css new file mode 100644 index 000000000..4927e5587 --- /dev/null +++ b/apps/client/src/print.css @@ -0,0 +1,5 @@ +html, +body { + width: 100%; + height: 100%; +} \ No newline at end of file diff --git a/apps/client/src/print.tsx b/apps/client/src/print.tsx index 267e2fdc4..ed3d83c6a 100644 --- a/apps/client/src/print.tsx +++ b/apps/client/src/print.tsx @@ -1,8 +1,8 @@ import { JSX } from "preact/jsx-runtime"; import FNote from "./entities/fnote"; import { render } from "preact"; -import { getComponentByViewTypeForPrint, useNoteIds, useViewModeConfig } from "./widgets/collections/NoteList"; -import { ViewTypeOptions } from "./widgets/collections/interface"; +import { CustomNoteList } from "./widgets/collections/NoteList"; +import "./print.css"; async function main() { const noteId = window.location.pathname.split("/")[2]; @@ -13,33 +13,26 @@ async function main() { let el: JSX.Element | null = null; if (note.type === "book") { - el = ; + el = handleCollection(note); } - render(el, document.body); -} - -function Collection({ note }: { note: FNote }) { - const viewType = note.getLabelValue("viewType") as ViewTypeOptions ?? "grid"; - const viewConfig = useViewModeConfig(note, viewType); - const noteIds = useNoteIds(note, viewType, "print"); - const component = getComponentByViewTypeForPrint(viewType, { - saveConfig() { - // While printing we don't allow for interactivity, so saving the config is a no-op. - }, - viewConfig: viewConfig?.[0] ?? {}, - note, - notePath: note.getBestNotePath().join("/"), - noteIds, - highlightedTokens: null - }); - - return ( + render(( <>

{note.title}

- - {component} + {el} + ), document.body); +} + +function handleCollection(note: FNote) { + return ( + ); } diff --git a/apps/client/src/widgets/collections/NoteList.tsx b/apps/client/src/widgets/collections/NoteList.tsx index d0ee5ed07..ba7d21d0c 100644 --- a/apps/client/src/widgets/collections/NoteList.tsx +++ b/apps/client/src/widgets/collections/NoteList.tsx @@ -13,7 +13,6 @@ import { subscribeToMessages, unsubscribeToMessage as unsubscribeFromMessage } f import { WebSocketMessage } from "@triliumnext/commons"; import froca from "../../services/froca"; import PresentationView from "./presentation"; -import PresentationPrintView from "./presentation/print"; interface NoteListProps { note: FNote | null | undefined; @@ -35,7 +34,7 @@ export function SearchNoteList(props: Omit } -function CustomNoteList({ note, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId }: NoteListProps) { +export function CustomNoteList({ note, isEnabled: shouldEnable, notePath, highlightedTokens, displayOnlyCollections, ntxId }: NoteListProps) { const widgetRef = useRef(null); const viewType = useNoteViewType(note); const noteIds = useNoteIds(note, viewType, ntxId); @@ -111,20 +110,6 @@ function getComponentByViewType(viewType: ViewTypeOptions, props: ViewModeProps< } } -export function getComponentByViewTypeForPrint(viewType: ViewTypeOptions, props: ViewModeProps) { - switch (viewType) { - case "list": - case "grid": - case "geoMap": - case "calendar": - case "table": - case "board": - return null; - case "presentation": - return - } -} - function useNoteViewType(note?: FNote | null): ViewTypeOptions | undefined { const [ viewType ] = useNoteLabel(note, "viewType"); diff --git a/apps/client/src/widgets/collections/presentation/print.tsx b/apps/client/src/widgets/collections/presentation/print.tsx deleted file mode 100644 index c2dadeb6f..000000000 --- a/apps/client/src/widgets/collections/presentation/print.tsx +++ /dev/null @@ -1,5 +0,0 @@ -import { ViewModeProps } from "../interface"; - -export default function PresentationPrintView(props: ViewModeProps) { - return

Hello world.

-}