Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
feat(print/table): integrate with the printing mechanism
Elian Doran0c5a6a75481b
diff --git a/apps/client/src/widgets/collections/table/TablePrintView.tsx b/apps/client/src/widgets/collections/table/TablePrintView.tsxindex abf73f1eee..9582b43600 100644--- a/apps/client/src/widgets/collections/table/TablePrintView.tsx+++ b/apps/client/src/widgets/collections/table/TablePrintView.tsx@@ -1,4 +1,4 @@-import { useRef, useState } from "preact/hooks";+import { useEffect, useRef, useState } from "preact/hooks";import { ViewModeProps } from "../interface";import useData, { TableConfig } from "./data";import { ExportModule, FormatModule, PrintModule, Tabulator as VanillaTabulator} from 'tabulator-tables';@@ -6,11 +6,16 @@ import Tabulator from "./tabulator";import { RawHtmlBlock } from "../../react/RawHtml";import "./TablePrintView.css";-export default function TablePrintView({ note, noteIds, viewConfig }: ViewModeProps<TableConfig>) {+export default function TablePrintView({ note, noteIds, viewConfig, onReady }: ViewModeProps<TableConfig>) {const tabulatorRef = useRef<VanillaTabulator>(null);const { columnDefs, rowData, hasChildren } = useData(note, noteIds, viewConfig, undefined, () => {});const [ html, setHtml ] = useState<string>();+ useEffect(() => {+ if (!html) return;+ onReady?.();+ }, [ html ]);+return rowData && (<><h1>{note.title}</h1>diff --git a/apps/client/src/widgets/ribbon/NoteActions.tsx b/apps/client/src/widgets/ribbon/NoteActions.tsxindex d7e344dd84..33017221be 100644--- a/apps/client/src/widgets/ribbon/NoteActions.tsx+++ b/apps/client/src/widgets/ribbon/NoteActions.tsx@@ -49,7 +49,7 @@ function NoteContextMenu({ note, noteContext }: { note: FNote, noteContext?: Notconst canBeConvertedToAttachment = note?.isEligibleForConversionToAttachment();const isSearchable = ["text", "code", "book", "mindMap", "doc"].includes(note.type);const isInOptionsOrHelp = note?.noteId.startsWith("_options") || note?.noteId.startsWith("_help");- const isPrintable = ["text", "code"].includes(note.type) || (note.type === "book" && ["presentation", "list"].includes(note.getLabelValue("viewType") ?? ""));+ const isPrintable = ["text", "code"].includes(note.type) || (note.type === "book" && ["presentation", "list", "table"].includes(note.getLabelValue("viewType") ?? ""));const isElectron = getIsElectron();const isMac = getIsMac();const hasSource = ["text", "code", "relationMap", "mermaid", "canvas", "mindMap", "aiChat"].includes(note.type);