import { useRef, useState } from "preact/hooks"; import { ViewModeProps } from "../interface"; import useData, { TableConfig } from "./data"; import { ExportModule, FormatModule, PrintModule, Tabulator as VanillaTabulator} from 'tabulator-tables'; import Tabulator from "./tabulator"; import { RawHtmlBlock } from "../../react/RawHtml"; import "./TablePrintView.css"; export default function TablePrintView({ note, noteIds, viewConfig }: ViewModeProps) { const tabulatorRef = useRef(null); const { columnDefs, rowData, hasChildren } = useData(note, noteIds, viewConfig, undefined, () => {}); const [ html, setHtml ] = useState(); return rowData && ( <>

{note.title}

{!html ? ( { const tabulator = tabulatorRef.current; if (!tabulator) return; const generatedTable = tabulator.modules.export.generateTable(tabulator.options.printConfig, tabulator.options.printStyled, tabulator.options.printRowRange, "print"); if(tabulator.options.printFormatter){ tabulator.options.printFormatter(tabulator.element, generatedTable); } setHtml(generatedTable.outerHTML); }} /> ) : ( )}
) }